[20210627]cursor_sharing=force与orade by.txt --//今天看了链接https://connor-mcdonald.com/2021/07/05/cursor_sharing-and-order-by/ --//实际上不知道是否巧合,前几天我也看到这句话. If a statement uses an ORDER BY clause, then the database does not perform literal replacement in the clause because it is not semantically correct to consider the constant column number as a literal. The column number in the ORDER BY clause affects the query plan and execution, so the database cannot share two cursors having different column numbers. --//我看到的这个内容来之sql-tuning-guide.pdf. 21c F31828-03 December 2020.我当时的测试就是不想上面说的情况. --//以前是我的测试: 1.环境: SCOTT@test01p> @ ver1 PORT_STRING VERSION BANNER CON_ID ------------------------------ -------------- -------------------------------------------------------------------------------- ---------- IBMPC/WIN_NT64-9.1.0 12.2.0.1.0 Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production 0 2.测试: SCOTT@test01p> alter session set cursor_sharing=force ; Session altered. SCOTT@test01p> select * from dept where deptno=10 order by 1; DEPTNO DNAME LOC ---------- -------------------- ------------- 10 ACCOUNTING NEW YORK SCOTT@test01p> @ dpc '' '' PLAN_TABLE_OUTPUT ------------------------------------- SQL_ID f2jf1h54abkzu, child number 0 ------------------------------------- select * from dept where deptno=:"SYS_B_0" order by :"SYS_B_1" Plan hash value: 2852011669 ---------------------------------------------------------------------------------------- | Id | Operation | Name | E-Rows |E-Bytes| Cost (%CPU)| E-Time | ---------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | 1 (100)| | | 1 | TABLE ACCESS BY INDEX ROWID| DEPT | 1 | 20 | 1 (0)| 00:00:01 | |* 2 | INDEX UNIQUE SCAN | PK_DEPT | 1 | | 0 (0)| | ---------------------------------------------------------------------------------------- Query Block Name / Object Alias (identified by operation id): ------------------------------------------------------------- 1 - SEL$9FB2EC53 / DEPT@SEL$1 2 - SEL$9FB2EC53 / DEPT@SEL$1 Predicate Information (identified by operation id): --------------------------------------------------- 2 - access("DEPTNO"=:SYS_B_0) --//替换发生,并没有链接介绍的情况. --//执行如下也是一样 select * from dept where deptno=10 order by 2; --//换一种方式: SCOTT@test01p> select * from dept where dname='ACCOUNTING' order by 2; DEPTNO DNAME LOC ---------- -------------------- ------------- 10 ACCOUNTING NEW YORK SCOTT@test01p> @ dpc '' '' PLAN_TABLE_OUTPUT ------------------------------------- SQL_ID 087vcgdqz87g9, child number 0 ------------------------------------- select * from dept where dname=:"SYS_B_0" order by :"SYS_B_1" Plan hash value: 3383998547 --------------------------------------------------------------------------- | Id | Operation | Name | E-Rows |E-Bytes| Cost (%CPU)| E-Time | --------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | 3 (100)| | |* 1 | TABLE ACCESS FULL| DEPT | 1 | 20 | 3 (0)| 00:00:01 | --------------------------------------------------------------------------- SCOTT@test01p> select * from dept where dname='ACCOUNTING' order by 1; DEPTNO DNAME LOC ---------- -------------------- ------------- 10 ACCOUNTING NEW YORK SCOTT@test01p> @ dpc '' '' PLAN_TABLE_OUTPUT ------------------------------------- SQL_ID 087vcgdqz87g9, child number 1 ------------------------------------- select * from dept where dname=:"SYS_B_0" order by :"SYS_B_1" Plan hash value: 3103054919 ---------------------------------------------------------------------------------------- | Id | Operation | Name | E-Rows |E-Bytes| Cost (%CPU)| E-Time | ---------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | 2 (100)| | |* 1 | TABLE ACCESS BY INDEX ROWID| DEPT | 1 | 20 | 2 (0)| 00:00:01 | | 2 | INDEX FULL SCAN | PK_DEPT | 4 | | 1 (0)| 00:00:01 | ---------------------------------------------------------------------------------------- Query Block Name / Object Alias (identified by operation id): ------------------------------------------------------------- 1 - SEL$1 / DEPT@SEL$1 2 - SEL$1 / DEPT@SEL$1 Predicate Information (identified by operation id): --------------------------------------------------- 1 - filter("DNAME"=:SYS_B_0) --//还是有效. select * from dept where dname='ACCOUNTING' order by 1,2; select * from dept where dname='ACCOUNTING' order by 2,1; select * from dept where dname='ACCOUNTING' order by 2,3; select * from dept where dname='ACCOUNTING' order by 3,2; --//一样有效,自不过产生许多子光标罢了.
[20210627]cursor_sharing=force与orade by.txt
来源:这里教程网
时间:2026-03-03 16:47:46
作者:
编辑推荐:
- [20210627]cursor_sharing=force与orade by.txt03-03
- 【PDB】Oracle 创建pdb说明(create pluggable database)03-03
- Oracle查看sql_id 的历史执行计划03-03
- 【BUG】Oracle12c tablespace io statistics missing from awr report03-03
- HTML 注册语言安信5-6-7代码+641480参考手册 HTML URL 编码 HTML03-03
- 甜蜜蜜的蜜雪冰城也发愁03-03
- [20210708]find -mtime +0 0 -0时间问题补充.txt03-03
- 删除分区 oracle asm disk 恢复03-03
下一篇:
相关推荐
-
雷神推出 MIX PRO II 迷你主机:基于 Ultra 200H,玻璃上盖 + ARGB 灯效
2 月 9 日消息,雷神 (THUNDEROBOT) 现已宣布推出基于英
-
制造商 Musnap 推出彩色墨水屏电纸书 Ocean C:支持手写笔、第三方安卓应用
2 月 10 日消息,制造商 Musnap 现已在海外推出一款 Oce
热文推荐
- 甜蜜蜜的蜜雪冰城也发愁
甜蜜蜜的蜜雪冰城也发愁
26-03-03 - 删除分区 oracle asm disk 恢复
删除分区 oracle asm disk 恢复
26-03-03 - 磁盘空间不足迁移数据文件导致故障恢复
磁盘空间不足迁移数据文件导致故障恢复
26-03-03 - ORACLE dbms_scheduler.create_job创建job作业遭遇PLS-00306
- 文件系统重新分区oracle恢复
文件系统重新分区oracle恢复
26-03-03 - ORA-600 16703故障解析—tab$表被清空
ORA-600 16703故障解析—tab$表被清空
26-03-03 - D77758CN20_sg1_Oracle Database 12c New Feather for DBA
- Oracle_11gR2_概念_中英文对照
Oracle_11gR2_概念_中英文对照
26-03-03 - Oracle 10053跟踪诊断SQL
Oracle 10053跟踪诊断SQL
26-03-03 - Oracle Database 11g RAC手册
Oracle Database 11g RAC手册
26-03-03
