1. 程式人生 > >[20170612]FOR ALL COLUMNS SIZE repeat(11g).txt

[20170612]FOR ALL COLUMNS SIZE repeat(11g).txt

ets session ogr bject ber procedure glob 註意 com

[20170612]FOR ALL COLUMNS SIZE repeat(11g).txt

--//昨天看了https://jonathanlewis.wordpress.com/2017/06/01/histogram-upgrade-2/,提到了直方圖的問題,
--//特別是FOR ALL COLUMNS SIZE repeat引起的問題,在一些特殊情況要註意.

1.環境:
[email protected]> @ &r/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

create table t (id number,pad varchar2(20),flag varchar2(1));
insert into t select rownum,lpad(‘a‘,20,‘a‘) ,‘a‘ from dual connect by level<=2e4;
insert into t select rownum+2e4,lpad(‘d‘,20,‘d‘) ,‘d‘ from dual connect by level<=2;
commit ;

[email protected]

/* */> SELECT flag, COUNT(*) FROM t GROUP BY flag;
F COUNT(*)
- ----------
d 2
a 20000

[email protected]> exec dbms_stats.Gather_table_stats(ownname => user, tabname => ‘T‘,method_opt => ‘FOR ALL COLUMNS ‘);
PL/SQL procedure successfully completed.

select * from DBA_TAB_COL_STATISTICS where owner=user and table_name=‘T‘ and column_name=‘FLAG‘;

Record View
As of: 2017/6/12 9:35:03

OWNER: SCOTT
TABLE_NAME: T
COLUMN_NAME: FLAG
NUM_DISTINCT: 2
LOW_VALUE: 61
HIGH_VALUE: 64
DENSITY: 0.000024997500249975
NUM_NULLS: 0
NUM_BUCKETS: 2
LAST_ANALYZED: 2017/6/12 9:33:35
SAMPLE_SIZE: 20002
GLOBAL_STATS: YES
USER_STATS: NO
AVG_COL_LEN: 2
HISTOGRAM: FREQUENCY

--//建立了直方圖.

[email protected]
/* */> set numw 36
[email protected]> select * from USER_TAB_HISTOGRAMS where column_name=‘FLAG‘;
TABLE_NAME COLUMN_NAME ENDPOINT_NUMBER ENDPOINT_VALUE ENDPOINT_A
---------- ----------- --------------- ------------------------------------ ----------
T FLAG 20000 503652795277878000000000000000000000
T FLAG 20002 519229685853483000000000000000000000

--//如果應用模式發生變化,加入了2種值.

insert into t select rownum+2e4+2,lpad(‘b‘,20,‘b‘) ,‘b‘ from dual connect by level<=2e4;
insert into t select rownum+4e4+2,lpad(‘c‘,20,‘c‘) ,‘c‘ from dual connect by level<=2;
commit ;

[email protected]
/* */> exec dbms_stats.Gather_table_stats(ownname => user, tabname => ‘T‘,method_opt => ‘FOR ALL COLUMNS size repeat‘,no_invalidate=> false);
PL/SQL procedure successfully completed.

select * from DBA_TAB_COL_STATISTICS where owner=user and table_name=‘T‘ and column_name=‘FLAG‘;

Record View
As of: 2017/6/12 9:38:59

OWNER: SCOTT
TABLE_NAME: T
COLUMN_NAME: FLAG
NUM_DISTINCT: 4
LOW_VALUE: 61
HIGH_VALUE: 64
DENSITY: 0.0000126552145963607
NUM_NULLS: 0
NUM_BUCKETS: 4
LAST_ANALYZED: 2017/6/12 9:38:10
SAMPLE_SIZE: 5432
GLOBAL_STATS: YES
USER_STATS: NO
AVG_COL_LEN: 2
HISTOGRAM: FREQUENCY

--//因為bucket桶變成了4個,直方圖依舊是FREQUENCY.

[email protected]> select * from USER_TAB_HISTOGRAMS where table_name=‘T‘ and column_name=‘FLAG‘;
TABLE_NAME COLUMN_NAME ENDPOINT_NUMBER ENDPOINT_VALUE ENDPOINT_A
---------- ----------- --------------- ------------------------------------ ----------
T FLAG 2775 503652795277878000000000000000000000
T FLAG 5430 508845092136413000000000000000000000
T FLAG 5431 514037388994948000000000000000000000
T FLAG 5432 519229685853483000000000000000000000

[email protected]> alter session set statistics_level=all;
Session altered.

[email protected]> select * from t where flag=‘c‘;
ID PAD F
----- -------------------- -
40003 cccccccccccccccccccc c
40004 cccccccccccccccccccc c

[email protected]> @ &r/dpc ‘‘ ‘‘
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID g3pmd0h5vnw5r, child number 0
-------------------------------------
select * from t where flag=‘c‘

Plan hash value: 1601196873

--------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time | A-Rows | A-Time | Buffers |
--------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | | 68 (100)| | 2 |00:00:00.01 | 204 |
|* 1 | TABLE ACCESS FULL| T | 1 | 7 | 196 | 68 (0)| 00:00:01 | 2 |00:00:00.01 | 204 |
--------------------------------------------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
1 - SEL$1 / [email protected]$1
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter("FLAG"=‘c‘)
23 rows selected.

--//可以發現E-rows 與 A-rows 差距不大,而12c的情況就不同了.12c如果使用method_opt => ‘FOR ALL COLUMNS size repeat‘後,
--//bucket=2,直方圖變成了混合型直方圖.也就是如果升級12c,要註意分析方法method_opt => ‘FOR ALL COLUMNS size repeat‘帶來的問題.
--//再寫有點長,另外寫看12c的測試.

--//當然如果數據模型沒有發生變化,問題可以不考慮.

[20170612]FOR ALL COLUMNS SIZE repeat(11g).txt

相關推薦

[20170612]FOR ALL COLUMNS SIZE repeat(11g).txt

ets session ogr bject ber procedure glob 註意 com [20170612]FOR ALL COLUMNS SIZE repeat(11g).txt--//昨天看了https://jonathanlewis.wordpress.com

[20170612]FOR ALL COLUMNS SIZE repeat(12c).txt

connect hash tar buck actual date validate block sql_id [20170612]FOR ALL COLUMNS SIZE repeat(12c).txt--//昨天看了https://jonathanlewis.wordp

live555: The input frame data was too large for our buffer size

rtsp采用Live555作為流媒體服務器端,進行RTSP的請求的時候,會出現如下的提示:MultiFramedRTPSink::afterGettingFrame1(): The input frame data was too large for our buffer size (100452). 13

[GeeksForGeeks] Populate inorder successor for all nodes in a binary search tree

stack iter pro get root following sin ice nod Given a binary search tree with the following tree node definition. next points to a node‘s

PL/SQL Developer登錄出現——Using a filter for all users can lead to poor performance!

objects default devel http mage eve 配置 tool cnblogs 用PL/SQL Developer登錄Oracle時提示:Using a filter for all users can lead to poor performan

weblogic啟動受管服務器報錯Authentication for user weblogic denied (weblogic 11g 域賬號密碼不生效的解決方法)

啟動 use authent image 技術 服務器 title for 賬號密碼 或者 解決方法: weblogic啟動受管服務器報錯Authentication for user weblogic denied (weblogic 11g 域賬號密碼不

[20171211]ora-16014 11g.txt

ply 情況 mon occurred ise port 滿了 sin chan [20171211]ora-16014 11g.txt--//上午測試了10g下備庫log_archive_dest_1參數配置VALID_FOR=(ONLINE_LOGFILES,ALL_R

roseMirrorHA5.0 for WindowsServer2008R2配合sqlserver2012|Oracle 11g的安裝和配置

HA enter 不能 server2 framework win alt 復制 2008r2 備註: 1.文字註釋解釋的是上面的圖片。 2.此文檔是在虛擬機中實驗做出來的,實際生產環境可能會遇到其他的問題。如果遇到解決不了的問題,請聯系我。 吐槽:為啥不能Word

[20180819]關於父子遊標問題(11g).txt

ber erp obsolete ssi tab ioi optimizer rod lin [20180819]關於父子遊標問題(11g).txt--//sql語句存在父子遊標,子遊標堆6在父遊標堆0裏面.--//如果存在許多子遊標的情況下,父遊標堆0是否大小是發生變化呢

How to Add “Open with Notepad” to the Windows Context Menu for All Files

If you want to open a file type not registered with Notepad, you have to click through several options to make it happen. This can be a hassle, so

Latest Ripple News for All the Ripple Crypto Fans

Ripple has always been the most controversial virtual currency. You must have continuously heard about much good news and bad news about

mycat執行報錯:java.sql.SQLException: java.lang.IllegalArgumentException: all columns in order by clause

普通sql語句: SELECT REC_ID,ORDER_UPDATE_RULE,ACTIVITY_ID FROM PLT_ACTIVITY_INFO WHERE ((ORDER_GEN_RULE = 1 OR ORDER_GEN_RULE = 2 ) AND TE

make[1]: Nothing to be done for `all-am'.

1.這句提示是說明你已經編譯好了,而且沒有對程式碼進行任何改動。 若想重新編譯,可以先刪除以前編譯產生的目標檔案: make clean make 2.也可以 make clean all make

Ask HN: Is the startup incentivisation valid for all national R&D strategies?

I'm a Spaniard, and startups are still in fashion. However, I still doubt if in all areas are suitable or there's any evidence of the increase in innovatio

One place for all your web apps | Hacker News

Hi HN,We're Alex and Julien, the founders of Station (https://getstation.com/). Our free desktop app unifies all your work applications in one neat interfa

Latin American Exchange Buda.com Adds Lightning Network Payments for All

As many of you already know, the main feature of the Lightning Network is that, in addition to being a way to pay Bitcoins with very low fees and practical

A searchable archive for all things infosec | Hacker News

We are a small group of security researchers. We are building a site to make everything searchable in the area of infosec.Every year there are more than a

Android Shared-Element Transitions for all

Android Shared-Element Transitions for allWe all want our apps to have its personality beyond material and, activitytransitions are a great way to make our

R語言︱函式使用技巧(迴圈、if族/for、switch、repeat、ifelse、stopifnot)

每每以為攀得眾山小,可、每每又切實來到起點,大牛們,緩緩腳步來俺筆記葩分享一下吧,please~———————————————————————————後續加更內容:應用一:if族有哪些成員呢?——if/ifelse/stopifnot應用二:如何在迴圈中,實時輸出時間消耗?—

對於不能join的表,使用for all entries in語句將該表與內表串聯。

像bseg這樣的表不是transparent table所以不能做inner join。在這種情況下,可以先從其他表中選出資料放到itab中,然後使用for all entries 語句來串聯。 如下:   SELECT bseg~kunnr bseg~lifnr bseg~