Oracle认证:ORACLE绑定变量BINDPEEKING
来源:才华咖 本文已影响1.4W人
来源:才华咖 本文已影响1.4W人
ORACLE 在9i之后引入了bind peeking,通过bind peeking,oracle可以在硬解析的时候窥探绑定变量的值,并根据当前绑定变量的值生成执行计划。在oracle 9i之前的版本中,oracle仅仅通过统计信息来生成执行计划。
下面看一下不同版本oracle下绑定变量对执行计划的影响
SQL> alter system flush shared_pool;
系统已更改。
SQL> alter system set optimizer_features_enable='8.1.7';
系统已更改。
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_lay_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;
系统已更改。
SQL> alter system set optimizer_features_enable='';
系统已更改。
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_lay_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;
系统已更改。
SQL> exec :v := 2;
PL/SQL 过程已成功完成。
SQL> select count(*) from acs_test_tab where record_type = :v;
COUNT(*)
----------
50000
SQL> select * from table(dbms_lay_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 |
高中英语作文:My approach to difficulties in learning
英语美文阅读:Kerry: Anti-IS Coalition Could Contribute to B
高中生优秀英语作文:Have a break away from electronics
Win10系统提示Officebackgroundtaskhandler.exe弹窗问题的解决方
Walk for children in poor areas英语作文
英语阅读:African Union Leaders Talk Mali, Chinese Investmen
Modern Technology Makes Life More Conv英语六级作文
英语短文:Celebration of Chinese New Year
The place of Science and Technology in Modern Life英语作文
英语作文:An unforgettable experience
英语口语:Teaching and Learning Responsibility
英语阅读范文参考:LovePeopleInAllKindsOfWeather
Should Private Cars Be Encouraged in China高中英语作文
Food and place of interest in Beijing初中英语作文
托福英语写作范文:Examinations exert a pernicious influence on educat
How I Finance My College Education英语作文
九年级《unit 6 I like music that I can dance to. Period2》评课稿
高中优秀英语作文An Unforgettable Experience
Ought Parents to Give Children Pocket英语作文
Fancy the original or movie ones大学英语作文
Little Pigs,the Crane and a Wolf英语故事短文
Will Robot Take the Place of Men英语作文
Passage Eighteen (Strictly Ban smoking)英语阅读理解
2015年12月四级考试作文预测范文:knowledge and experience
Unforgettable experience 难忘的一件事作文
英语作文Some advice on how to learn English well
oracle 笔试
The Sprint in College Entrance Exam英语作文
OneRepublic演唱的Apologize钢琴谱
Oracle认证:ORACLE绑定变量BINDPEEKING
To Be a Good Talker and Listener初中英语作文
Health in developing countries大学六级英语写作范文
英语作文:The Importance of Self-confidence
Djokovic Fulfilled Career Grand英语作文
英语作文:Reading Outside The College
Learning to Ride Bikes大学英语作文
oracle学习心得
oracle同义词
人教PEP版小学五年级英语下册Unit3Myschoolcalender.ALet’stalk
A Bitter Experience in My Childhood初中英语作文