<dfn id="w48us"></dfn><ul id="w48us"></ul>
  • <ul id="w48us"></ul>
  • <del id="w48us"></del>
    <ul id="w48us"></ul>
  • Oracle認(rèn)證:ORACLE綁定變量BINDPEEKING

    時(shí)間:2024-08-25 15:57:01 Oracle認(rèn)證 我要投稿
    • 相關(guān)推薦

    Oracle認(rèn)證:ORACLE綁定變量BINDPEEKING

      ORACLE 在9i之后引入了bind peeking,通過bind peeking,oracle可以在硬解析的時(shí)候窺探綁定變量的值,并根據(jù)當(dāng)前綁定變量的值生成執(zhí)行計(jì)劃。在oracle 9i之前的版本中,oracle僅僅通過統(tǒng)計(jì)信息來生成執(zhí)行計(jì)劃。

      下面看一下不同版本oracle下綁定變量對執(zhí)行計(jì)劃的影響

      SQL> alter system flush shared_pool;

      系統(tǒng)已更改。

      SQL> alter system set optimizer_features_enable='8.1.7';

      系統(tǒng)已更改。

      SQL> var v number;

      SQL> exec :v := 1;

      PL/SQL 過程已成功完成。

      SQL> select count(*) from acs_test_tab where record_type = :v;

      COUNT(*)

      ----------

      1

      SQL> select * from table(dbms_xplan.display_cursor(null,null,'advanced'));

      PLAN_TABLE_OUTPUT

      ----------------------------------------------------------------------------------------------------

      SQL_ID3rg5r8sghcvb3, child number 0

      -------------------------------------

      select count(*) from acs_test_tab where record_type = :v

      Plan hash value: 2956728990

      --------------------------------------------------------------------------------

      | Id | Operation | Name | Rows | Bytes | Cost |

      --------------------------------------------------------------------------------

      | 0 | SELECT STATEMENT | | | | 3 |

      | 1 | SORT AGGREGATE | | 1 | 4 | |

      |* 2 | INDEX RANGE SCAN| ACS_TEST_TAB_RECORD_TYPE_I | 2 | 8 | 3 |

      --------------------------------------------------------------------------------

      Predicate Information (identified by operation id):

      ---------------------------------------------------

      2 - access("RECORD_TYPE"=:V)

      已選擇47行。

      SQL> alter system flush shared_pool;

      系統(tǒng)已更改。

      SQL> alter system set optimizer_features_enable='11.2.0.3.1';

      系統(tǒng)已更改。

      SQL> var v number;

      SQL> exec :v := 1;

      PL/SQL 過程已成功完成。

      SQL> select count(*) from acs_test_tab where record_type = :v;

      COUNT(*)

      ----------

      1

      SQL> select * from table(dbms_xplan.display_cursor(null,null,'advanced'));

      PLAN_TABLE_OUTPUT

      ----------------------------------------------------------------------------------------------------

      SQL_ID3rg5r8sghcvb3, child number 0

      -------------------------------------

      select count(*) from acs_test_tab where record_type = :v

      Plan hash value: 2956728990

      ------------------------------------------------------------------------------------------------

      | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |

      ------------------------------------------------------------------------------------------------

      | 0 | SELECT STATEMENT | | | | 3 (100)| |

      | 1 | SORT AGGREGATE | | 1 | 4 | | |

      |* 2 | INDEX RANGE SCAN| ACS_TEST_TAB_RECORD_TYPE_I | 1 | 4 | 3 (0)| 00:00:01 |

      ------------------------------------------------------------------------------------------------

      Peeked Binds (identified by position):

      --------------------------------------

      1 - :V (NUMBER): 1 --綁定變量窺探

      Predicate Information (identified by operation id):

      ---------------------------------------------------

      2 - access("RECORD_TYPE"=:V)

      已選擇49行。

      SQL> alter system flush shared_pool;

      系統(tǒng)已更改。

      SQL> exec :v := 2;

      PL/SQL 過程已成功完成。

      SQL> select count(*) from acs_test_tab where record_type = :v;

      COUNT(*)

      ----------

      50000

      SQL> select * from table(dbms_xplan.display_cursor(null,null,'advanced'));

      PLAN_TABLE_OUTPUT

      ----------------------------------------------------------------------------------------------------

      SQL_ID3rg5r8sghcvb3, child number 0

      -------------------------------------

      select count(*) from acs_test_tab where record_type = :v

      Plan hash value: 2957754476

      ----------------------------------------------------------------------------------------------------

      | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |

      ----------------------------------------------------------------------------------------------------

      | 0 | SELECT STATEMENT | | | | 136 (100)| |

      | 1 | SORT AGGREGATE | | 1 | 4 || |

      |* 2 | INDEX FAST FULL SCAN| ACS_TEST_TAB_RECORD_TYPE_I | 48031 | 187K| 136 (1)| 00:00:02 |

      ----------------------------------------------------------------------------------------------------

      Peeked Binds (identified by position):

      --------------------------------------

      1 - :V (NUMBER): 2 --綁定變量窺探,綁定變量會(huì)影響最初硬解析的執(zhí)行計(jì)劃

      Predicate Information (identified by operation id):

      ---------------------------------------------------

      2 - filter("RECORD_TYPE"=:V)

      已選擇49行。

      使用綁定變量窺測的好處是:可以幫助優(yōu)化器在第一次硬解析時(shí)選擇最優(yōu)的執(zhí)行計(jì)劃。但是同時(shí)這也是其弊端:在第一次硬解析后,后面發(fā)生的所有解析都會(huì)使用第一次硬解析生成的執(zhí)行計(jì)劃,如果數(shù)據(jù)的分布是均勻的,問題不大,如果數(shù)據(jù)分布式傾斜的,那么第一次硬解析生成的執(zhí)行計(jì)劃未必是最優(yōu)的,甚至可能是非常糟糕的。例如:

      SQL> show parameter optimizer_feat

      NAME TYPE VALUE

      ------------------------------------ ----------- ------------------------------

      optimizer_features_enable string 11.2.0.3.1

      SQL> alter system flush shared_pool;

      系統(tǒng)已更改。

      SQL> var v number;

      SQL> exec :v := 2;

      PL/SQL 過程已成功完成。

      SQL> select count(*) from acs_test_tab where record_type = :v;

      COUNT(*)

      ----------

      50000

      SQL> select * from table(dbms_xplan.display_cursor);

      PLAN_TABLE_OUTPUT

      ----------------------------------------------------------------------------------------------------

      SQL_ID3rg5r8sghcvb3, child number 0

      -------------------------------------

      select count(*) from acs_test_tab where record_type = :v

      Plan hash value: 2957754476

      ----------------------------------------------------------------------------------------------------

      | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |

      ----------------------------------------------------------------------------------------------------

      | 0 | SELECT STATEMENT | | | | 136 (100)| |

      | 1 | SORT AGGREGATE | | 1 | 4 || |

      |* 2 | INDEX FAST FULL SCAN| ACS_TEST_TAB_RECORD_TYPE_I | 48031 | 187K| 136 (1)| 00:00:02 |

      ----------------------------------------------------------------------------------------------------

      Predicate Information (identified by operation id):

      ---------------------------------------------------

      2 - filter("RECORD_TYPE"=:V)

      已選擇19行。

      SQL> exec :v := 1

      PL/SQL 過程已成功完成。

      SQL> select count(*) from acs_test_tab where record_type = :v;

      COUNT(*)

      ----------

      1

      SQL> select * from table(dbms_xplan.display_cursor);

      PLAN_TABLE_OUTPUT

      ----------------------------------------------------------------------------------------------------

      SQL_ID3rg5r8sghcvb3, child number 0

      -------------------------------------

      select count(*) from acs_test_tab where record_type = :v

      Plan hash value: 2957754476

      ----------------------------------------------------------------------------------------------------

      | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |

      ----------------------------------------------------------------------------------------------------

      | 0 | SELECT STATEMENT | | | | 136 (100)| |

      | 1 | SORT AGGREGATE | | 1 | 4 || |

      |* 2 | INDEX FAST FULL SCAN| ACS_TEST_TAB_RECORD_TYPE_I | 48031 | 187K| 136 (1)| 00:00:02 |

      ----------------------------------------------------------------------------------------------------

      Predicate Information (identified by operation id):

      ---------------------------------------------------

      2 - filter("RECORD_TYPE"=:V)

      已選擇19行。

      SQL> select count(*) from acs_test_tab where record_type = 1;

      COUNT(*)

      ----------

      1

      SQL> select * from table(dbms_xplan.display_cursor);

      PLAN_TABLE_OUTPUT

      ----------------------------------------------------------------------------------------------------

      SQL_ID1pxm87f6yd0bp, child number 0

      -------------------------------------

      select count(*) from acs_test_tab where record_type = 1

      Plan hash value: 2956728990

      ------------------------------------------------------------------------------------------------

      | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |

      ------------------------------------------------------------------------------------------------

      | 0 | SELECT STATEMENT | | | | 3 (100)| |

      | 1 | SORT AGGREGATE | | 1 | 4 | | |

      |* 2 | INDEX RANGE SCAN| ACS_TEST_TAB_RECORD_TYPE_I | 1 | 4 | 3 (0)| 00:00:01 |

      ------------------------------------------------------------------------------------------------

      Predicate Information (identified by operation id):

      ---------------------------------------------------

      2 - access("RECORD_TYPE"=1)

      已選擇19行。

      對于變量v的取值為1的執(zhí)行計(jì)劃和采用常量1的執(zhí)行計(jì)劃性能差距還是比較大的。

      總結(jié):oracle在9i后引入變量窺測技術(shù),該技術(shù)對于數(shù)據(jù)分布均勻的數(shù)據(jù)是非常合適的,但是對于分布傾斜的數(shù)據(jù)或者在OLAP系統(tǒng)中是不建議使用的。

    【Oracle認(rèn)證:ORACLE綁定變量BINDPEEKING】相關(guān)文章:

    Oracle認(rèn)證作用03-19

    Oracle認(rèn)證簡介11-30

    Oracle最新認(rèn)證03-09

    Oracle認(rèn)證途徑03-20

    Oracle認(rèn)證:Oracle控制件文件修復(fù)03-18

    Oracle認(rèn)證:Oracle內(nèi)存結(jié)構(gòu)研究-PGA篇03-08

    Oracle認(rèn)證:Oracle避免全表掃描方式03-08

    Oracle認(rèn)證職業(yè)前景03-19

    Oracle認(rèn)證考試技巧03-19

    主站蜘蛛池模板: 久久精品成人影院| 午夜亚洲av永久无码精品 | 久久久久久亚洲精品不卡| 国产精品丝袜一区二区三区| 无翼乌无遮挡全彩老师挤奶爱爱帝国综合社区精品 | 国内精品视频九九九九| 国产亚洲精品一品区99热| 亚洲国产精品无码中文字| 精品一区二区三区在线观看| 午夜精品免费在线观看| 成人伊人精品色XXXX视频| 欧美亚洲色综久久精品国产| 天天爽夜夜爽夜夜爽精品视频| 国产精品JIZZ在线观看老狼| 国产成人精品精品欧美| 久久精品国产清高在天天线| 亚洲精品无码不卡在线播HE| 色婷婷噜噜久久国产精品12p| 精品国产一区二区三区免费| 国产精品VA在线观看无码不卡| 伊人久久精品影院| 完整观看高清秒播国内外精品资源| 国产成人精品福利网站在线观看| 日韩精品一区二区三区四区 | 久久免费精品视频| 凹凸69堂国产成人精品视频| 国产精品极品| 99久久www免费人成精品| 国内精品久久久久影院免费| 国产精品三级在线观看无码| 久久99热只有频精品8| 久久精品国产亚洲av水果派| 日产欧美国产日韩精品| 日韩精品久久久久久免费| 日韩人妻无码精品一专区| 亚洲精品狼友在线播放| 亚洲精品亚洲人成在线观看下载| 亚欧洲精品在线视频免费观看| 欧美精品一二区| 中文字幕日韩精品在线| 无码国产精品一区二区免费式芒果|