Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Order SQL runs

Status
Not open for further replies.

Kreiss

Programmer
Oct 8, 2003
48
US
I thought I've heard this before, but not for sure. What is the order that SQL runs the where conditions? For example I have a query that takes forever to run with several where conditions, and thought if my first check was to get only males that would cut the run by 50% by not having to check all the other conditions for both male and female. Hopefully this is clear enough.

Thanks,
Kacy

 
To be sure my advice would be to use a proper tool to run an explain plan on the query you are using. This will give you the exact details on how the query is executed and how DB2 optimizer 'rewrites' the query based upon its own internal 'intelligence'.

I fear that optimizing is more that reshuffling the order of the where parts. You will want to know how indexes are used (if any) , where full table scans are performed.

Are you performing an order by on the resulting dataset?
That can be crippling to performance!

T. Blom
Information analyst
tbl@shimano-eu.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top