View previous topic :: View next topic |
Author |
Message |
bullfighter Beginner
Joined: 15 Apr 2005 Posts: 26 Topics: 9
|
Posted: Tue Apr 26, 2005 6:57 pm Post subject: order of the where clause in SQL |
|
|
hi
does the order of parameter checks in the Where Clause of an SQL matter the performance.
If Index is defined in the order COL1, COL2, COL3
then would it be more efficient if my where clause has first COL1 check then COL2 check and then COL3 check..??
Thanks |
|
Back to top |
|
|
CZerfas Intermediate
Joined: 31 Jan 2003 Posts: 211 Topics: 8
|
Posted: Wed Apr 27, 2005 5:42 am Post subject: |
|
|
Yes, the ordering of predicates in the WHERE clause is relevant for performance. Although, the predicates used to access an index are interpreted first by DB2.
Relevant is this ordering for non-indexed predicates. There the suggestion is to use the one first which filters most. An example: if you don't have indexes for "gender" or "postal code", and you look for male customers living in a particular town, then code the predicate searching for a certain "postal code" before you search for "gender".
This of course is only relevant if you scan millions of records.
regards
Christian |
|
Back to top |
|
|
bullfighter Beginner
Joined: 15 Apr 2005 Posts: 26 Topics: 9
|
Posted: Fri Apr 29, 2005 3:25 pm Post subject: |
|
|
thanks christian _________________ champion is not one who never fails, but one who never quits |
|
Back to top |
|
|
|
|