Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

DB2 Explains Itself: A Roadmap to Faster Query Runtime

DB2 creates a plan for each dynamic SQL query you run. Evaluating this plan is one of the keys to query runtime efficiency. In this 10-Minute Solution, DB2 Pro Greg Nash shows you how to use DB2's explain facility to identify and correct the planning weaknesses that are slowing your queries down.


advertisement
ave you ever wondered why some of your queries take so long to run? Or how DB2 interprets your requests?

As with all high-level programming languages, SQL must be translated into a set of smaller operations, which can be performed in turn. Because the efficiency of each operation can vary greatly with the nature of the data, considerable attention should be paid to selecting the best order of operations.

You can compare this with shopping. There may be many paths from your home to the shop you need to visit. You might want to park as close to the shop as you can, or perhaps park further away to avoid parking station costs and queuing to leave. There may be a smaller shop closer to home that has what you want. You may want to avoid a busy road. The best shopping path isn't always obvious, and you could waste hours though poor planning.



To shorten a query's runtime, you need to locate any weaknesses in the operation planning. How? IBM's online documentation boasts: "DB2 provides the most comprehensive explain facility in the industry with detailed optimizer information on the access plan chosen for an explained SQL statement." The explain facility outlines how the database will go about your work. This allows you to identify and correct any inefficiencies in your query planning.



How can I make my queries faster?



Use DB2's EXPLAIN feature to access and evaluate how it plans to access your data.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date