exists、in的运用场景
exists、in的运用场景 能不写子查询,尽量不写子查询,而是直接编写多表连接操作。理由如下: ① oracle CBO在parse阶段,会尽可能把子查询转化为多表连接 ② 子查询可...
in、or与union all的性能对比
in、or与union all的性能对比对于某大表的查询 使用or: SELECT * FROM article WHERE article_category=2 OR article_category=3 // 执行时间:11.0777 使用 in: SELECT * FROM article WHERE article_category IN (2,3) // 执行时间:11.2850 使用union all: SELECT * FROM article WHERE article...
9i and 10g 通过SQL_ADDRESS 或sql_id查询执行计划
V$SQL_PLAN, DBMS_XPLAN.DISPLAY_CURSOR:If you know sql_id or the set of (hash_value, address) of the shared cursor, you can get the correct plan using V$SQL_PLAN or DBMS_XPLAN.DISPLAY_CURSOR. Make sure the calling user has privileges on fixed following views: V$SQL_PLAN_STATISTICS_ALL, V$SQL ...
oracle hint /*+ BYPASS_UJVC*/ 使用案例
var B2 number;exec :B2:=530;var B1 number;exec :B1:=201411;UPDATE PRERPT.STATQ_WRTOFF_PLYD_PRE P SET GFLAG = 1 WHERE EXISTS (SELECT 1 FROM PRERPT.STATB_GROUP_ACCOUNT T WHERE T.REGION = :B2 AND T.CYCLE = :B1AND T.ACCTID = P.ACCTID )该语句由于没有选择正确的执行计划,导致语句非常慢Plan ha...
v$Sql_bind_capture 时间变量无法显示
通过v$sql_bind_capture可以查到绑定变量的实际值,该视图的刷新时间间隔受隐含参数_cursor_bind_capture_interval 控制,默认情况下为900秒,但对于timestamp类型的值,直接查询此视图是无法看到绑定值的,需要通过函数转换:select sql_id,name,position,value_string from V$sql_Bind_Capture where sql_id='6...
HINT no_swap_join_inputs/swap_join_inputs
10G以后hash_join可以通过no_swap_join_inputs/swap_join_inputs来强制控制build表,配合leading或者ordered可以控制多表之前的连接顺序。 >select 2 /*+ 3 ordered 4 use_hash(t2) 5 use_hash(t3) 6...
通过_optimizer_rownum_pred_based_fkr优化一条sql语句
一生产库,cpu利用率达到95%以上,通过分析发现是由一条sql语句影响,通过设置参数 _optimizer_rownum_pred_based_fkr来解决------采样时间看数据库负载很高 -------sharepool 占用了大量的内存(说明数据里存在的硬解析较高,存大大量的字面值) ...
在收集统计信息时指定method_opt=>.. size auto 时,有可能不收集直方图
DBMS_STATS With METHOD_OPT =>'..SIZE auto' May Not Collect Histograms (文档 ID 557594.1)在收集统计信息时指定method_opt=>.. size auto 时,有可能不收集直方图。APPLIES TO:Oracle Server - Enterprise Edition - Version 10.2.0.1 and laterInformation in this document applies to any platform.S...