--最慢速度(無索引)
drop
table t purge
;create
table t as
select
*from dba_objects;
alter
table t modify object_name not
null
;select
count(*
)from t;
set autotrace traceonly
set linesize 1000
set timing on
select
count(*
)from t;
/--快了一點(有普通索引)
drop
table t purge
;create
table t as
select
*from dba_objects;
alter
table t modify object_name not
null
;create
index idx_object_name on t(object_name)
;set autotrace traceonly
set timing on
select
count(*
)from t;
/--又快一點(有了乙個合適的點陣圖索引)
drop
table t purge
;create
table t as
select
*from dba_objects;
update t set object_name=
'abc'
;update t set object_name=
'evf'
where rownum<=
20000
;create bitmap index idx_object_name on t(object_name)
;set autotrace traceonly
set timing on
select
count(*
)from t;
/注:如果記錄數不重複或者說重複度很低,oracle會選擇全表掃瞄,如果用
來強制,可以發現效能很低下。
alter
session
set statistics_level=
all;
set linesize 1000
set pagesize 1
select
/*+index(t,idx_object_name)*/
count(*
)from test t;
select
*from
table
(dbms_xplan.display_cursor(
null
,null
,'allstats last'))
;--再快一點(物化檢視,注意使用的場景)
drop materialized view mv_count_t;
drop
table t purge
;create
table t as
select
*from dba_objects;
update t set object_name=
'abc'
;update t set object_name=
'evf'
where rownum<=
20000
;create materialized view mv_count_t
build immediate
refresh on
commit
enable query rewrite
asselect
count(*
)from t;
set autotrace traceonly
set linesize 1000
select
count(*
)from t;
/--又再快一點(快取結果集,也是要注意使用的場景)
drop
table t purge
;create
table t as
select
*from dba_objects;
select
count(*
)from t;
set linesize 1000
set autotrace traceonly
select
/*+ result_cache */
count(*
)from t;
/--速度之王來咯!(原來需求才是王道)
select
count(*
)from t where rownum=
1;
題解三十四
輸入整數陣列 arr 找出其中最小的 k 個數。例如,輸入4 5 1 6 2 7 3 8這8個數字,則最小的4個數字是1 2 3 4。示例 1 輸入 arr 3,2,1 k 2 輸出 1,2 或者 2,1 示例 2 思路 我們可以使用乙個大小為 k 的大頂堆,將陣列中的元素依次入堆,當堆的大小超過 ...
GNU make manual 翻譯 三十四
繼續翻譯 a directive is an instruction for make to do something special while reading the makefile.these include reading another makefile note including o...
CUDA學習(三十四)
c語言擴充套件 函式執行空間說明符 函式執行空間說明符表示函式是在主機上還是在裝置上執行,以及函式是從主機還是從裝置中呼叫。device device 執行空間說明符宣告乙個函式 global 和 device 執行空間說明符不能一起使用。global 空間說明符將乙個函式宣告為乙個核心。這樣的功能...