何时Oracle使用绑定变量性能反而更差
2007-05-09 12:12:50 来源:WEB开发网我们看下索引扫描的代价是多少:SQL> show parameter OPTIMIZER_INDEX_COST_ADJ
NAME TYPE VALUE
------------------------------------ ----------- ------
optimizer_index_cost_adj integer 100
SQL> delete from plan_table;
0 rows deleted.
SQL>
SQL> explain plan for select
/*+index(a T_PEEKING_IDX1)*/ * from T_PEEKING a where b = :V;
Explained.
SQL> select lpad(' ', 2*(level-1))||operation||' '||options||' '||
2 object_name||' '||decode(id, 0, 'Cost='||position) "Query
3 Plan_Table"
4 from plan_table
5 start with id = 0
6 connect by prior id = parent_id
7 ;
Query
Plan_Table
-----------------------------------------------------
SELECT STATEMENT Cost=113
TABLE ACCESS BY INDEX ROWID T_PEEKING
INDEX RANGE SCAN T_PEEKING_IDX1
SQL>
再看全表扫描的代价是多少:SQL> delete from plan_table;
3 rows deleted.
SQL>
SQL> explain plan for select
/*+full(a)*/ * from T_PEEKING a where b = :V;
Explained.
SQL>
SQL> select lpad(' ', 2*(level-1))||operation||' '||options||' '||
2 object_name||' '||decode(id, 0, 'Cost='||position) "Query
3 Plan_Table"
4 from plan_table
5 start with id = 0
6 connect by prior id = parent_id
7 ;
Query
Plan_Table
----------------------------------------------------
SELECT STATEMENT Cost=75
TABLE ACCESS FULL T_PEEKING
SQL>
- ››使用linux中的quota教程
- ››oracle 中 UPDATE nowait 的使用方法
- ››Oracle ORA-12560解决方法
- ››Oracle 10g RAC 常用维护命令
- ››Oracle如何在ASM中定位文件的分布
- ››使用jxl生成带动态折线图的excel
- ››Oracle的DBMS_RANDOM.STRING 的用法
- ››oracle 外部表导入时间日期类型数据,多字段导入
- ››Oracle中查找重复记录
- ››oracle修改用户登录密码
- ››Oracle创建删除用户、角色、表空间、导入导出等命...
- ››Oracle中登陆时报ORA-28000: the account is lock...
更多精彩
赞助商链接