no_unnest与unnest
看了pub上一篇关于no_unnest的文章后学习了一番,照着做了一下测试,加深理解:unnest我们称为对子查询展开,顾名思义,就是别让子查询孤单地嵌套(nest)在里面。所以un_unnest双重否定代表肯定,即让子查询不展开,...
使用sql tunig advisor
1.首先收集表的统计信息。SQL> exec dbms_stats.gather_table_stats(user,'EMP',cascade=>true);PL/SQL procedure successfully completed.2.插入大量数据,并更新表里的数据,使val列都是唯一值,造成统计信息过...
通过v$session_longops监控事务回滚进度
在日常管理中,可能会遇到长时间的事务回滚,通过查看v$session_longops视图,可以获知这些事务回滚需要的时间,以下是测试过程:在session 1中执行事务回滚:session 1:SQL> select sid from v$mystat where rown...
优化器何时使用density作为选择率
ser_tab_columns视图里,有两列NUM_DISTINCT和DENSITY,如果没有收集直方图,这两列的值是相同的,SQL> exec dbms_stats.gather_table_stats(user,'T1',cascade=>true,estimate_percent => null,method_opt=>'for a...
初试EM
一直使用sqlplus来管理数据库,最近尝试了一下EM,感觉还是比较好用的。----卸载oracle@primary ebank]$ emca -deconfig dbcontrol dbSTARTED EMCA at Jul 1, 2010 7:24:42 AMEM Configuration Assistant, Version...
shrink 与rebuild对索引高度的影响对比
测试思路: 创建一个测试表t1,并创建索引,插入数据后,再将数据删除,然后对表和索引进行shrink操作,观察索引高度是否发生变化:SQL> create table t1 as select * from dba_objects; &n...
listener的动态注册与service_name
动态注册的listener.ora,由netca产生:[oracle@primary admin]$ cat listener.ora # listener.ora Network Configuration File: /home/db/oracle/product/10.2.0/network/admin/listener.ora# Generated by Oracle...
dbms_stats包不收集long字段长度信息
测试如下:SQL> create table test(a char(1),b long) tablespace users;Table created.SQL> insert into test values('1','aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
等待事件--read by other session
最近一个生产库里出现大量db file scattered read和read by other session的等待,看了一下相关sql,都是对一个大表做全表扫描,10g官方文档里关于read by other session的解释如下:read by other sessionThis ev...
统计信息有误导致B-tree to Bitmap Conversions
生产库cpu使用率增加,查看awr报告可见如下sql的cpu time较高: 条sql 的执行计划是一样的,查看其执行计划:SQL> select child_number from v$sql where sql_id='cdp2vwt31665p'; &nb...
execute和fetch
关于execute和fetch这两个阶段,到底是怎么区分的,一直感到迷惑,做个测试,可以大概看个明白:SQL> alter session set events '10046 trace name context forever,level 12';Session altered.SQL> select count...
对表的shrink都做了些什么
SQL> truncate table rate;Table truncated.SQL> insert into rate values('a',1);1 row created.SQL> insert into rate values('b',2);1 row created.SQL> insert into rate values('c',3);1 row created.S...
捕捉尝试登陆失败的用户信息
最近一个应用的用户被锁,查了一下发现在profile里设置了100次尝试登陆的限制,为了定位具体尝试登陆的时间及ip等相关信息,需要写一个trigger进行捕捉,以下来自网上:create or replace trigger logon_denied_to_...
optimizer_index_caching在何时生效
关于optimizer_index_caching,在《基于成本的oracle优化法则》一书中作者提到过:optimizer_index_caching is used to adjust the cost calculation for index blocks of the inner table innested loops and for ...
索引的pctfree什么时候有效?
tom曰:pctfree only counts when BUILDING an index. It reserves X% of the block for subsequent inserts into that block (inserts into the block can arise from inserts or UPDATES to the base table)...
等待事件模拟(二)cursor: pin S wait on X
这是10.2版本提出的mutex(互斥)机制用来解决library cache bin latch争夺问题引入的新事件,是否使用这种机制受到隐含参数_kks_use_mutex_pin的限制,从10.2.0.2开始该参数default为true,使用这种机制oracle是为了解决...
等待事件模拟(一)latch:library cache
1,创建2个sequence.create sequence seq_0;create sequence seq_1;2.创建过程,循环打开并关闭游标,模拟大量的parse。create or replace procedure p( p_n in number )as &n...
重建索引可能带来的问题(二)
1.测试思想: 分别创建两个相同的表rebuild和norebuild,在每个表的id列上创建索引,对两个表进行同样的delete操作,然后对rebuild表上的索引进行重建,norebuild表上的索引保持不变。开启2个sess...
重建索引可能带来的问题(一)
问题一;重建后索引使用空间增大,如下测试:SQL> desc bowie Name &nb...
使用dbms_space.space_usage
记在这里,方便查找:set serveroutput on size 10000;declarev_unformatted_blocks number;v_unformatted_bytes number;v_fs1_blocks number;v_fs1_bytes number;v_fs2_blocks number;v_fs2_bytes number;v_fs3_bl...