Results 1 to 2 of 2

Thread: Doubt with SQL

  1. #1
    Join Date
    Mar 2003
    Location
    Singapore
    Posts
    200

    Unanswered: Doubt with SQL

    Hi all,

    I would like to know whether would there be change in performance or explain plan if we switch the conditions in the where clause.
    Below is a same SQL but the conditons are changed.Also will it make change if we reverse the join parameter ie:a.a=b.a and b.a=a.a are both thses the same.
    Ex:
    select a,b from tab1 a,tab2 b
    where a.a=b.a and b.id>10
    and a.time=120;

    select a,b from tab1 a,tab2 b
    where b.id>10 and a.a=b.a
    and a.time=120;


    Thanks and regards
    micky

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    It matters if you are using the rule-based optimizer (RBO), but not for the cost-based optimizer (CBO). The CBO considers lots of different plans, and chooses the "cheapest"; it will decide which predicate to apply first according to which leads to the cheapest plan.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •