http://www.searu.org/19178.html
ALTER SESSION SET optimizer_features_enable = '10.2.0.4';
ALTER SESSION SET optimizer_dynamic_sampling = 2;
ALTER SESSION SET EVENTS '10046 TRACE NAME CONTEXT FOREVER, LEVEL 12';
alter index idx_1 rebuild reverse;
start setenv
execute dbms_random.seed(0)
begin
begin execute immediate 'purge recyclebin'; --清空回收站
exception when others then null;
end;
begin
dbms_stats.set_system_stats('MBRC',8); --多块读取为8块
dbms_stats.set_system_stats('MREADTIM',26); --对块读取平均时间为26毫秒
dbms_stats.set_system_stats('SREADTIM',12); --单块读取平均时间为30毫秒
dbms_stats.set_system_stats('CPUSPEED',800); --cpu每秒可执行800,000,000个操作
exception
when others then null;
end;
begin execute immediate 'begin dbms_stats.delete_system_stats; end;'; --删除系统统计信息
exception when others then null;
end;
begin execute immediate 'alter session set "_optimizer_cost_model"=io'; --基于io来计算估值
exception when others then null;
end;
end;
/
Oracle 11g R2 全表扫描成本计算(工作量模式-workload)
ALTER SESSION SET optimizer_features_enable = '10.2.0.4';
ALTER SESSION SET optimizer_dynamic_sampling = 2;
ALTER SESSION SET EVENTS '10046 TRACE NAME CONTEXT FOREVER, LEVEL 12';
alter index idx_1 rebuild reverse;
start setenv
execute dbms_random.seed(0)
begin
begin execute immediate 'purge recyclebin'; --清空回收站
exception when others then null;
end;
begin
dbms_stats.set_system_stats('MBRC',8); --多块读取为8块
dbms_stats.set_system_stats('MREADTIM',26); --对块读取平均时间为26毫秒
dbms_stats.set_system_stats('SREADTIM',12); --单块读取平均时间为30毫秒
dbms_stats.set_system_stats('CPUSPEED',800); --cpu每秒可执行800,000,000个操作
exception
when others then null;
end;
begin execute immediate 'begin dbms_stats.delete_system_stats; end;'; --删除系统统计信息
exception when others then null;
end;
begin execute immediate 'alter session set "_optimizer_cost_model"=io'; --基于io来计算估值
exception when others then null;
end;
end;
/