How to consider Explain plan as good- Oracle 10G

余生长醉 提交于 2019-12-11 03:13:50

问题


When an oracle explained plan is consider good? I'm try to refactor a DB Schema, and there are so many query in view and packages that are so slow.

For example, this is one of the most orrible query, and give me this explain plan:

Plan ALL_ROWSCost: 18,096 Bytes: 17 Cardinality: 1

I don't ask how to fix a query, just how to consider the explain plan as good. Thanks!!


回答1:


Before considering the result of an Explain Plan we need to understand following terminologies, Cardinality– Estimate of the number of rows coming out of each of the operations.
• Access method – The way in which the data is being accessed, via either a table scan or index access. • Join method – The method (e.g., hash, sort-merge, etc.) used to join tables with each other. • Join type – The type of join (e.g., outer, anti, semi, etc.). • Join order – The order in which the tables are joined to each other.
• Partition pruning – Are only the necessary partitions being accessed to answer the query?
• Parallel Execution – In case of parallel execution, is each operation in the plan being conducted in parallel? Is the right data redistribution method being used?

By reviewing the four key elements of: cardinality estimations, access methods, join methods, and join orders; you can determine if the execution plan is the best available plan. This white paper will help you, http://www.oracle.com/technetwork/database/focus-areas/bi-datawarehousing/twp-explain-the-explain-plan-052011-393674.pdf




回答2:


The cost estimate is oracles educated guess on how many blocks it will need to visit in order to answer your query. Is 18,096 a good number? That depends on what you are doing, how fast your server is and how quick you need it to run. There is little meaning in this number as an absolute value.

If you change the SQL or and indexes and the cost estimate goes down that is a good sign but what really matters is how long when it actually ruins. Oracle can estimate badly at times.

Having said all that it looks a bit high for something that runs while a user waits but reasonable for a batch job.



来源:https://stackoverflow.com/questions/13838173/how-to-consider-explain-plan-as-good-oracle-10g

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!