How do you interpret a query's explain plan?

后端 未结 11 1704
鱼传尺愫
鱼传尺愫 2020-12-02 05:12

When attempting to understand how a SQL statement is executing, it is sometimes recommended to look at the explain plan. What is the process one should go through in interpr

11条回答
  •  清歌不尽
    2020-12-02 05:36

    The two examples below show a FULL scan and a FAST scan using an INDEX.

    It's best to concentrate on your Cost and Cardinality. Looking at the examples the use of the index reduces the Cost of running the query.

    It's a bit more complicated (and i don't have a 100% handle on it) but basically the Cost is a function of CPU and IO cost, and the Cardinality is the number of rows Oracle expects to parse. Reducing both of these is a good thing.

    Don't forget that the Cost of a query can be influenced by your query and the Oracle optimiser model (eg: COST, CHOOSE etc) and how often you run your statistics.

    Example 1:

    SCAN http://docs.google.com/a/shanghainetwork.org/File?id=dd8xj6nh_7fj3cr8dx_b

    Example 2 using Indexes:

    INDEX http://docs.google.com/a/fukuoka-now.com/File?id=dd8xj6nh_9fhsqvxcp_b

    And as already suggested, watch out for TABLE SCAN. You can generally avoid these.

提交回复
热议问题