通过 Oracle 的解释计划进行查询的总成本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5851284/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 23:33:08  来源:igfitidea点击:

Total cost of a query through Oracle's explain plan

sqldatabaseoracleoracle11g

提问by Maya

I am a bit new to Oracle and I am have a question regarding Oracle's explain plan. I have used the 'auto-trace' feature for a particular query.

我对 Oracle 有点陌生,我对 Oracle 的解释计划有疑问。我对特定查询使用了“自动跟踪”功能。

SQL> SELECT * from myTable; 11 rows selected. Elapsed: 00:00:00.01

SQL> SELECT * from myTable; 已选择 11 行。经过:00:00:00.01

Execution Plan
----------------------------------------------------------
Plan hash value: 1233351234

----------------------------------------------------------------------------
| Id  | Operation         | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
----------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |        |    11 |   330 |     3   (0)| 00:00:01 |
|   1 |  TABLE ACCESS FULL| MYTABLE|    11 |   330 |     3   (0)| 00:00:01 |
----------------------------------------------------------------------------

My question is if I want to calculate the 'total' cost of this query, is it 6 (3+3) or its only 3. Suppose I had a larger query with more steps in the plan, do I have to add up all the values in the cost column to get the total cost or is it the first value (ID=0) that is the total cost of a query?

我的问题是,如果我想计算这个查询的“总”成本,是 6 (3+3) 还是只有 3。假设我有一个更大的查询,计划中有更多的步骤,我是否必须把所有的都加起来成本列中的值以获得总成本还是查询总成本的第一个值(ID = 0)?

回答by BeeOnRope

Cost is 3, the plan is shown as a hierarchy, with the cost of the sub-components already included in the parent components.

成本为 3,计划显示为层次结构,子组件的成本已包含在父组件中。

回答by Andrew

You might also want to take a look at some of the responses to: How do you interpret a query's explain plan?

您可能还想查看一些对以下问题的回复: 您如何解释查询的解释计划?