Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003
    Posts
    1

    Angry Unanswered: SQL Query Question - Please Help : )

    Hi,

    I am working on a query like the following:

    select a.f1,b.f2,c.f3
    from t1 as a
    join t2 as b
    on a.id=b.id
    left join t3 as c
    on b.id2=c.id2
    where a.type in ('a','b','c');

    someone told me that it is not efficient because all rows in table a will be readed before the where statement is used to narrow down the population. Is this true? If so, if I change the query as the following, will the performance be improved?

    select a.f1,b.f2,c.f3
    from t1 as a
    join t2 as b
    on a.id=b.id
    and a.type in ('a','b','c');
    left join t3 as c
    on b.id2=c.id2
    ;

    Thanks for your help : )

  2. #2
    Join Date
    Jan 2003
    Posts
    1,605
    Hi,

    According to my knowleadge the SQL's are the same. Ther DB2 rewriter will most probably rewrite the SQL. Try using SQL explain to see the access path or use the visual explain from Command Center.

    You can also read the following thread about Performance.

    Hope this helps,
    Grofaty

  3. #3
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    Your explain will also give you the Optimized SQL ... This will help you to understand how DB2 has 'rewritten' your statement

    Cheers
    Sathyaram
    Visit the new-look IDUG Website , register to gain access to the excellent content.

Posting Permissions

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