[20210202]計算標量子查詢快取數量2.txt
[20210202]計算標量子查詢快取數量2.txt
--//昨天做了計算標量子查詢快取數量的測試,實際上還有1個簡單的方法測試,就是看執行計劃,
--//唯一的方式就是開啟statistics_level = all,或者設定提示gather_plan_statistics.
--//透過例子說明:
1.環境:
SCOTT@book> @ ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
2.測試:
create table t1 tablespace users
as
with generator as (
select --+ materialize
rownum id
from all_objects
where rownum <= 3000
)
select
/*+ ordered use_nl(v2) */
rownum n1,
lpad(rownum,16,'0') v16,
lpad(rownum,32,'0') v32
from
generator v1,
generator v2
where
rownum <= 16384
;
insert /*+ append */ into t1 select * from t1;
commit;
begin
dbms_stats.gather_table_stats(
user,
't1',
cascade => true,
estimate_percent => null,
method_opt => 'for all columns size 1'
);
end;
/
create or replace package pack1 as
g_ct number(10) := 0;
function f_n(i in number) return number;
function f_v(i in varchar2) return varchar2;
function f_vn(i in varchar2) return number;
end;
/
create or replace package body pack1 as
function f_n(i in number) return number
is
begin
dbms_application_info.set_client_info(userenv('client_info')+1 );
return i;
end;
function f_v(i in varchar2) return varchar2
is
begin
dbms_application_info.set_client_info(userenv('client_info')+1 );
return i;
end
;
function f_vn(i in varchar2) return number
is
begin
dbms_application_info.set_client_info(userenv('client_info')+1 );
return length(i);
end
;
end;
/
3.測試:
SCOTT@book> select count(distinct x) from ( select /*+ gather_plan_statistics no_merge */ (select pack1.f_n(n1) from dual) x from t1) ;
COUNT(DISTINCTX)
----------------
16384
SCOTT@book> @ dpc '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID cvqr6u5a0yq15, child number 0
-------------------------------------
select count(distinct x) from ( select /*+ gather_plan_statistics
no_merge */ (select pack1.f_n(n1) from dual) x from t1)
Plan hash value: 2761048924
-------------------------------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time | A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem |
-------------------------------------------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | | 81 (100)| | 1 |00:00:00.31 | 275 | | | |
| 1 | FAST DUAL | | 31744 | 1 | | 2 (0)| 00:00:01 | 31744 |00:00:00.01 | 0 | | | |
| 2 | SORT AGGREGATE | | 1 | 1 | 13 | | | 1 |00:00:00.31 | 275 | | | |
| 3 | VIEW | VW_DAG_0 | 1 | 32768 | 416K| 81 (3)| 00:00:01 | 16384 |00:00:00.31 | 275 | | | |
| 4 | HASH GROUP BY | | 1 | 32768 | 416K| 81 (3)| 00:00:01 | 16384 |00:00:00.31 | 275 | 3072K| 2891K| 1843K (0)|
| 5 | VIEW | | 1 | 32768 | 416K| 79 (0)| 00:00:01 | 32768 |00:00:00.29 | 275 | | | |
| 6 | TABLE ACCESS FULL| T1 | 1 | 32768 | 160K| 79 (0)| 00:00:01 | 32768 |00:00:00.01 | 275 | | | |
-------------------------------------------------------------------------------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
1 - SEL$3 / DUAL@SEL$3
2 - SEL$C33C846D
3 - SEL$5771D262 / VW_DAG_0@SEL$C33C846D
4 - SEL$5771D262
5 - SEL$2 / from$_subquery$_001@SEL$1
6 - SEL$2 / T1@SEL$2
29 rows selected.
--//id=2,starts=31744,說明呼叫函式次數是31744.
--//16384*2-31744 = 1024
--//hash table size=1024.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2755293/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20210201]19c計算標量子查詢快取數量.txt快取
- 20180601]函式與標量子查詢2.txt函式
- [20200325]慎用標量子查詢.txt
- MYSQL學習筆記25: 多表查詢(子查詢)[標量子查詢,列子查詢]MySql筆記
- MYSQL count標量子查詢改left joinMySql
- 方法快取與查詢快取
- redis 快取 singlefly 查詢Redis快取
- [20211220]關於標量子查詢問題.txt
- Oracle常用抓取SQL-標量子查詢等OracleSQL
- mysql 標量子查詢和現金盤程式製作非法子查詢MySql
- IBM量子計算機亮相 距離標準量子計算機相距甚遠IBM計算機
- [20180626]函式與標量子查詢14.txt函式
- [20180625]函式與標量子查詢13(補充)函式
- [20180612]函式與標量子查詢10.txt函式
- [20180611]函式與標量子查詢9.txt函式
- [20180607]函式與標量子查詢8.txt函式
- [20180602]函式與標量子查詢4.txt函式
- [20180602]函式與標量子查詢3.txt函式
- [20211214]18c標量子查詢unnest.txt
- mysql查詢快取簡單使用MySql快取
- 影響Oracle標量子查詢效能的三個因素Oracle
- 快取遞迴計算快取遞迴
- 【TUNE_ORACLE】列出有標量子查詢的SQL參考OracleSQL
- day03-商家查詢快取02快取
- GreatSQL 最佳化技巧:將 MINUS 改寫為標量子查詢SQL
- day02-2-商鋪查詢快取快取
- 微服務複雜查詢之快取策略微服務快取
- 在 Linux/Unix/Mac 下清除 DNS 查詢快取LinuxMacDNS快取
- Laravel Eloquent 關聯模型查詢快取資料Laravel模型快取
- 入門量子計算
- 前沿科技:量子計算
- mysql查詢語句陣列下標擷取MySql陣列
- MySQL的查詢快取功能何時該開啟MySql快取
- MySQL:查詢欄位數量多少對查詢效率的影響MySql
- Amazon Braket 與量子計算
- 遊標查詢
- MUI呼叫原生自定義方法實現計算快取與清空快取UI快取
- 計算機論文查詢網站計算機網站