[20200120]12c線上統計收集問題.txt
[20200120]12c線上統計收集問題.txt
--//昨天看連結:http://blog.go-faster.co.uk/2020/01/on-line-statistics-gathering-disabled.html
--//重複測試:
1.環境:
SCOTT@test01p> @ ver1
PORT_STRING VERSION BANNER CON_ID
------------------------------ -------------- -------------------------------------------------------------------------------- ----------
IBMPC/WIN_NT64-9.1.0 12.2.0.1.0 Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production 0
CREATE TABLE t1(a number, b varchar2(1000), c number);
CREATE TABLE t2(a number, b varchar2(1000), c number);
exec dbms_stats.set_table_prefs(user,'t1','METHOD_OPT','FOR ALL COLUMNS SIZE AUTO FOR COLUMNS SIZE 254 C');
TRUNCATE TABLE t1;
EXEC dbms_stats.delete_table_stats(user,'T1');
INSERT /*+APPEND*/ INTO t1
SELECT ROWNUM a, TO_CHAR(TO_DATE(rownum,'J'),'Jsp') b, CEIL(SQRT(rownum)) c FROM dual CONNECT BY level <= 1e4;
commit ;
TRUNCATE TABLE t2;
EXEC dbms_stats.delete_table_stats(user,'T2');
INSERT /*+APPEND*/ INTO t2
SELECT ROWNUM a, TO_CHAR(TO_DATE(rownum,'J'),'Jsp') b, CEIL(SQRT(rownum)) c FROM dual CONNECT BY level <= 1e4;
COMMIT;
2.測試:
SCOTT@test01p> SELECT table_name, num_rows, last_analyzed FROM user_tables WHERE table_name LIKE 'T_' ORDER BY 1;
TABLE_NAME NUM_ROWS LAST_ANALYZED
-------------------- ---------- -------------------
T1
T2 10000 2020-01-20 09:42:46
SCOTT@test01p> SELECT table_name, column_name, num_distinct, histogram, num_buckets FROM user_tab_columns WHERE table_name LIKE 'T_' ORDER BY 1,2;
TABLE_NAME COLUMN_NAME NUM_DISTINCT HISTOGRAM NUM_BUCKETS
-------------------- -------------------- ------------ --------------- -----------
T1 A NONE
T1 B NONE
T1 C NONE
T2 A 10000 NONE 1
T2 B 10000 NONE 1
T2 C 100 NONE 1
6 rows selected.
--//可以發現T1表沒有統計資訊,因為它事先使用dbms_stats.set_table_prefs定義了特殊統計收集方式。
--//摘要:http://blog.go-faster.co.uk/2020/01/on-line-statistics-gathering-disabled.html
It appears that I don't get statistics on T1 because I have specified a table statistics preference that is specific to
some named columns. It doesn't have to specify creating a histogram, it might be preventing a histogram from being
created.
For example, this preference does not disable on-line statistics collection.
EXEC dbms_stats.set_table_prefs(user,'t2','METHOD_OPT','FOR ALL COLUMNS SIZE 1');
But these preferences do disable on-line statistics collection.
EXEC dbms_stats.set_table_prefs(user,'t2','METHOD_OPT','FOR COLUMNS SIZE 1 B C');
EXEC dbms_stats.set_table_prefs(user,'t2','METHOD_OPT','FOR COLUMNS SIZE 1 A B C');
I have not found any other statistics preferences (for other DBMS_STATS parameters) that cause this behaviour.
Conclusion
Table preferences are recommended as a method of controlling statistics collection declaratively and consistently. You
don't have to specify parameters to DBMS_STATS into scripts that collect statistics ad-hoc. The table statistics
preferences provide a method that every time statistics are collected on a particular table, they are collected
consistently, albeit in a way that may be different from the default.
However, take the example of an ETL process loading data into a data warehouse. If you rely on on-line statistics
gathering to collect table statistics as a part of a data load process, you must now be careful not to disable
statistics collection during the load with METHOD_OPT statistics preferences.
Autonomous Addendum
In the Oracle Autonomous Data Warehouse, in order to make statistics collection as self-managing as possible, Oracle
sets two undocumented parameters.
_optimizer_gather_stats_on_load_hist=TRUE - so that histograms are created on every column when on-line statistics are
gathered
_optimizer_gather_stats_on_load_all=TRUE - so that on-line statistics are collected for every direct-path insert, not
just the first one.
Creating a column specific METHOD_OPT statistics preference disables this behaviour.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2674064/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20200120]12c Group by Elimination bug.txt
- [20200819]12c Global Temporary table 統計資訊的收集的疑問.txt
- [20181006]12c使用toad連線問題.txt
- [20181026]12c增強索引線上DDL操作.txt索引
- [20230308]12c以上版本模糊查詢問題.txt
- [20181031]12c 線上移動資料檔案.txt
- [20200120]ORA-54033 ORA-30556.txt
- 12C 線上MOVE
- [20220811]奇怪的隱式轉換問題(12c補充測試).txt
- [20200711]關於左右連線的問題.txt
- 線上FullGC問題排查實踐——手把手教你排查線上問題GC
- [20230124]12c訪問login.sql指令碼.txtSQL指令碼
- 線上問題集錦(1)
- 線上問題集錦(2)
- [20200120]oracle wait event "enq: SQ – contention" and DBA_DB_LINK_SOURCES.txtOracleAIENQ
- [20181128]toad連線資料庫的問題.txt資料庫
- 手動收集——收集統計資訊
- [20230306]os認證連線資料庫問題.txt資料庫
- xshell連線不上linux問題Linux
- 入駐線上教育saas系統會面臨哪些問題?
- [20181128]toad連線資料庫的問題(補充).txt資料庫
- APP接入友盟統計,不上報資料問題APP
- 線上問題總結-獲取不到連線池(logback 配置+程式碼問題)
- 如何做線上問題覆盤
- 一次線上OOM問題分析OOM
- 線上問題排查神器入門——Arthas
- 企業管理系統上線後可能會面臨哪些問題?
- 線上賬務系統餘額併發更新問題記錄
- [20210812]windows xcopy問題.txtWindows
- [20190221]sql patch 問題.txtSQL
- [20181217]strace使用問題.txt
- [20181204]bbed修改問題.txt
- [20190313]備份問題.txt
- [20180619]bbed verify問題.txt
- 收集統計資訊方案
- Oracle收集統計資訊Oracle
- [20190929]bash使用bc計算的相關問題.txt
- [20190930]關於資料結構設計問題.txt資料結構