How do I use DB2 Explain?

后端 未结 4 2054
我在风中等你
我在风中等你 2020-12-08 21:08

How do I use DB2\'s Explain function? -- both to run it, and to use it to optimize queries. Is there a better tool available for DB2?

I\'ve built queries before, bu

4条回答
  •  忘掉有多难
    2020-12-08 21:33

    What you're looking for is covered by two DB2 utilities:

    1. The explain utility, which shows the optimizer's access plan and estimated cost for a specific query (based on current RUNSTATS statistics)
    2. The design advisor, which recommends structural changes to improve the performance of one or more queries

    Both utilities require specialized tables to be created in the database.

    I tend to use the explain utility more than the advisor, especially if I am able to change the SQL for the query to influence a better access plan. I use the db2expln command-line utility to explain different versions of a query I'm tuning and compare their costs. What's most important is that your table and index statistics are up to date when running explain or the design advisor.

提交回复
热议问题