by Pastaman on May 15th, 2006

Pastaman

Question

Help answer this question below.

What are the first things to look for when optimizing SQL queries?

Answers. 2 helpful answers below.

  • by topcat on January 14th, 2010

    topcat

    First you need to understand how your database is executing your query. There are database-specific commands for this.

    After the result of your analysis comes back, you'll want to make sure index is used as much as possible. Vertical or horizontal partitioning should also be considered. Other things to look for include the design of the database schema and how the database server is configured.

    This Query Optimization page has more information on this topic.

    No comments. Post one | Permalink

  • by sandman35 on May 22nd, 2006

    sandman35

    I can answer this question for oracle SQL. I am a DBA and this is usually a complex and time consuming area of my job. The first thing to do is run an explain plan of your SQL, if you cannot do this then ask your DBA to help. This contains cost of the query as well as other hints to show what it would typically do if you take the code live. Look for obvious things in the explain plan, such as cartesian join - NOT GOOD - or full table scans where indexes should be used, or index range scans where index to table rowid can be achieved. Learn how to ask for and made proper use of indexes. Learn how to use inner and outer joins, and the use of sub-queries. There is a LOT more to look at but this should give you a good start.

    No comments. Post one | Permalink

Want to attach an image to your answer? Click here.

Did this answer your question? If not, then ask a new question or create a poll.

You're reading What are the first things to look for when optimizing SQL queries?

Follow us on Facebook!

Related Ads