cf调优完整版本
2016-10-23 20:30
351 查看
--20161023--cf调优实验
drop table TEST7;
create table TEST7(deptno PRIMARY KEY ,dname)as
select object_id,a.OBJECT_NAME from all_objects a where a.OBJECT_ID<1000 order by a.OBJECT_NAME;
drop table TEST8
create table TEST8(deptno PRIMARY KEY ,dname)as
select object_id,a.OBJECT_NAME from all_objects a where a.OBJECT_ID<1000 order by a.OBJECT_ID desc;
--查询
select t.deptno,t.dname
from (select a.deptno,a.dname,
row_number() over(partition by a.dname order by rownum) rn
from TEST7 a --where a.deptno=8
) t
where t.rn = 1;
/* 统计信息
----------------------------------------------------------
31 recursive calls
0 db block gets
19 consistent gets
0 physical reads
0 redo size
25390 bytes sent via SQL*Net to client
1054 bytes received via SQL*Net from client
60 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
878 rows processed*/
select a.deptno,a.dname
from TEST7 a
where a.rowid =
(select min(rowid) from TEST7 b where b.dname = a.dname);
/* 统计信息
----------------------------------------------------------
57 recursive calls
0 db block gets
131 consistent gets
0 physical reads
0 redo size
25390 bytes sent via SQL*Net to client
1054 bytes received via SQL*Net from client
60 SQL*Net roundtrips to/from client
6 sorts (memory)
0 sorts (disk)
878 rows processed */
-- EXEC DBMS_STATS.gather_index_stats(USER, 'DEPTNO');
EXEC dbms_stats.gather_table_stats(USER,'TEST7');
EXEC dbms_stats.gather_table_stats(USER,'TEST8');
--查看聚簇因子:
select b.table_name,
a.index_name,
b.num_rows,
b.blocks,
a.clustering_factor
from user_indexes a, user_tables b
where b.table_name in ('TEST7', 'TEST8')
and a.table_name = b.table_name;
TABLE_NAME INDEX_NAME NUM_ROWS BLOCKS CLUSTERING_FACTOR
------------------------------ ------------------------------ ---------- ---------- -----------------
TEST7 SYS_C0010510 883 3 406
TEST8 SYS_C0010513 883 3 3
-- TEST7 cf值与nr值相近,计划很差
-- cf调优
-- tuncate原表
truncate table TEST7;
--按序临时表
drop table TEST7_temp;
create table TEST7_temp(deptno PRIMARY KEY ,dname) as
select object_id,a.OBJECT_NAME from all_objects a where a.OBJECT_ID<1000 order by a.object_id desc;
--重新插入值
insert into TEST7 select * from TEST7_temp;
--查看聚簇因子:
EXEC dbms_stats.gather_table_stats(USER,'TEST7');
EXEC dbms_stats.gather_table_stats(USER,'TEST8');
select b.table_name,
a.index_name,
b.num_rows,
b.blocks,
a.clustering_factor
from sys.user_indexes a, sys.user_tables b
where b.table_name in ('TEST7', 'TEST8')
and a.table_name = b.table_name;
TABLE_NAME INDEX_NAME NUM_ROWS BLOCKS CLUSTERING_FACTOR
------------------------------ ------------------------------ ---------- ---------- -----------------
TEST7 SYS_C0010525 883 3 3
TEST8 SYS_C0010528 883 3 3
--查询
select t.deptno,t.dname
from (select a.deptno,a.dname,
row_number() over(partition by a.dname order by rownum) rn
from TEST7 a --where a.deptno=8
) t
where t.rn = 1;
/*
统计信息
----------------------------------------------------------
1 recursive calls
0 db block gets
5 consistent gets
0 physical reads
0 redo size
25390 bytes sent via SQL*Net to client
1054 bytes received via SQL*Net from client
60 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
878 rows processed
*/
select a.deptno,a.dname
from TEST7 a
where a.rowid =
(select min(rowid) from TEST7 b where b.dname = a.dname);
/* 统计信息
----------------------------------------------------------
1 recursive calls
0 db block gets
10 consistent gets
0 physical reads
0 redo size
25390 bytes sent via SQL*Net to client
1054 bytes received via SQL*Net from client
60 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
878 rows processed*/
drop table TEST7;
create table TEST7(deptno PRIMARY KEY ,dname)as
select object_id,a.OBJECT_NAME from all_objects a where a.OBJECT_ID<1000 order by a.OBJECT_NAME;
drop table TEST8
create table TEST8(deptno PRIMARY KEY ,dname)as
select object_id,a.OBJECT_NAME from all_objects a where a.OBJECT_ID<1000 order by a.OBJECT_ID desc;
--查询
select t.deptno,t.dname
from (select a.deptno,a.dname,
row_number() over(partition by a.dname order by rownum) rn
from TEST7 a --where a.deptno=8
) t
where t.rn = 1;
/* 统计信息
----------------------------------------------------------
31 recursive calls
0 db block gets
19 consistent gets
0 physical reads
0 redo size
25390 bytes sent via SQL*Net to client
1054 bytes received via SQL*Net from client
60 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
878 rows processed*/
select a.deptno,a.dname
from TEST7 a
where a.rowid =
(select min(rowid) from TEST7 b where b.dname = a.dname);
/* 统计信息
----------------------------------------------------------
57 recursive calls
0 db block gets
131 consistent gets
0 physical reads
0 redo size
25390 bytes sent via SQL*Net to client
1054 bytes received via SQL*Net from client
60 SQL*Net roundtrips to/from client
6 sorts (memory)
0 sorts (disk)
878 rows processed */
-- EXEC DBMS_STATS.gather_index_stats(USER, 'DEPTNO');
EXEC dbms_stats.gather_table_stats(USER,'TEST7');
EXEC dbms_stats.gather_table_stats(USER,'TEST8');
--查看聚簇因子:
select b.table_name,
a.index_name,
b.num_rows,
b.blocks,
a.clustering_factor
from user_indexes a, user_tables b
where b.table_name in ('TEST7', 'TEST8')
and a.table_name = b.table_name;
TABLE_NAME INDEX_NAME NUM_ROWS BLOCKS CLUSTERING_FACTOR
------------------------------ ------------------------------ ---------- ---------- -----------------
TEST7 SYS_C0010510 883 3 406
TEST8 SYS_C0010513 883 3 3
-- TEST7 cf值与nr值相近,计划很差
-- cf调优
-- tuncate原表
truncate table TEST7;
--按序临时表
drop table TEST7_temp;
create table TEST7_temp(deptno PRIMARY KEY ,dname) as
select object_id,a.OBJECT_NAME from all_objects a where a.OBJECT_ID<1000 order by a.object_id desc;
--重新插入值
insert into TEST7 select * from TEST7_temp;
--查看聚簇因子:
EXEC dbms_stats.gather_table_stats(USER,'TEST7');
EXEC dbms_stats.gather_table_stats(USER,'TEST8');
select b.table_name,
a.index_name,
b.num_rows,
b.blocks,
a.clustering_factor
from sys.user_indexes a, sys.user_tables b
where b.table_name in ('TEST7', 'TEST8')
and a.table_name = b.table_name;
TABLE_NAME INDEX_NAME NUM_ROWS BLOCKS CLUSTERING_FACTOR
------------------------------ ------------------------------ ---------- ---------- -----------------
TEST7 SYS_C0010525 883 3 3
TEST8 SYS_C0010528 883 3 3
--查询
select t.deptno,t.dname
from (select a.deptno,a.dname,
row_number() over(partition by a.dname order by rownum) rn
from TEST7 a --where a.deptno=8
) t
where t.rn = 1;
/*
统计信息
----------------------------------------------------------
1 recursive calls
0 db block gets
5 consistent gets
0 physical reads
0 redo size
25390 bytes sent via SQL*Net to client
1054 bytes received via SQL*Net from client
60 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
878 rows processed
*/
select a.deptno,a.dname
from TEST7 a
where a.rowid =
(select min(rowid) from TEST7 b where b.dname = a.dname);
/* 统计信息
----------------------------------------------------------
1 recursive calls
0 db block gets
10 consistent gets
0 physical reads
0 redo size
25390 bytes sent via SQL*Net to client
1054 bytes received via SQL*Net from client
60 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
878 rows processed*/
相关文章推荐
- 解决“此版本的 SQL Server 不支持用户实例登录标志。该连接将关闭”问题,完整综合版。
- 个性化推荐十大挑战[科普+完整版本] 精选
- linux下安装部署redis及使用jedis访问redis server简单的完整流程(简洁版本)
- JavaWeb环境搭建完整版本(jdk+tomcat+svn+maven)
- DotNetNuke4.x安装心得(按照下面那篇《最完整的DNN 4.X 安装攻略(适合3.X版本)》安装还是失败的朋友进来看看
- 游戏开发完整学习路线(各个版本都有)
- 解决“此版本的 SQL Server 不支持用户实例登录标志。该连接将关闭”问题,完整综合版。
- ACM PKU 题目分类(完整整理版本)
- 关于“Android SDK manager中不出现完整Android版本安装包列表”的动态解决方法
- API接口规范完整版本(续) · Issue #129 · mishe/blog
- viewport手机逻辑像素与物理像素原理(附完整手机各版本尺寸)
- 运行mahout0.6 hadoop版本的CF
- 把附件(WORD、EXCEL、PDF)或图片存贮到数据库的完整范例程序。(MYSQL、SQL SERVER、ORACLE)三个版本
- MySQL性能调优my.cnf详解(mysql5.6版本)
- ACM POJ 题目分类(完整整理版本)
- 新Oracle Form开发标准培训文档(完整版本)
- UBIFS文件系统简介 与 利用mkfs.ubifs和ubinize两个工具制作UBI镜像 (完整理解版本)
- 游戏开发完整学习路线(各个版本都有)
- 虚拟机安装windows ghost版本系统记录完整过程
- Spark2.0_Spark全面精讲(基于Spark2版本+含Spark调优+超多案例)