一個很好的指令碼,用來顯示cbo的統計資訊
發表人: | 發表時間: 2007年一月09日, 19:38
Select to show Optimizer Statistics for CBO,Note:31412.1
Instructions | |
---|---|
Execution Environment: SQL*Plus Access Privileges: Requires select privileges on dba_tables, dba_tab_columns, dba_indexes, dba_ind_columns Usage: sqlplus | |
Description | |
The following select statement can be used to display the optimizer statistics related to a particular table. The script will ask for Table Name and Owner to show Statistics for. The default Owner is the current user. |
一個很好的指令碼,用來顯示cbo的統計資訊
發表人: | 發表時間: 2007年一月09日, 19:38
Select to show Optimizer Statistics for CBO,Note:31412.1
Instructions | |
---|---|
References | |
none | |
Script | |
set echo off set scan on set lines 150 set pages 66 set verify off set feedback off set termout off column uservar new_value Table_Owner noprint select user uservar from dual; set termout on column TABLE_NAME heading "Tables owned by &Table_Owner" format a30 select table_name from dba_tables where owner=upper('&Table_Owner') order by 1 / undefine table_name undefine owner prompt accept owner prompt 'Please enter Name of Table Owner (Null = &Table_Owner): ' accept table_name prompt 'Please enter Table Name to show Statistics for: ' column TABLE_NAME heading "Table|Name" format a15 column PARTITION_NAME heading "Partition|Name" format a15 column SUBPARTITION_NAME heading "SubPartition|Name" format a15 column NUM_ROWS heading "Number|of Rows" format 9,999,990 column BLOCKS heading "Blocks" format 999,990 column EMPTY_BLOCKS heading "Empty|Blocks" format 999,990 column AVG_SPACE heading "Average|Space" format 9,990 column CHAIN_CNT heading "Chain|Count" format 990 column AVG_ROW_LEN heading "Average|Row Len" format 990 column COLUMN_NAME heading "Column|Name" format a25 column NULLABLE heading Null|able format a4 column NUM_DISTINCT heading "Distinct|Values" format 99,990 column NUM_NULLS heading "Number|Nulls" format 99,990 column NUM_BUCKETS heading "Number|Buckets" format 990 column DENSITY heading "Density" format 990 column INDEX_NAME heading "Index|Name" format a15 column UNIQUENESS heading "Unique" format a9 column BLEV heading "B|Tree|Level" format 90 column LEAF_BLOCKS heading "Leaf|Blks" format 990 column DISTINCT_KEYS heading "Distinct|Keys" format 9,999,990 column AVG_LEAF_BLOCKS_PER_KEY heading "Average|Leaf Blocks|Per Key" format 99,990 column AVG_DATA_BLOCKS_PER_KEY heading "Average|Data Blocks|Per Key" format 99,990 column CLUSTERING_FACTOR heading "Cluster|Factor" format 999,990 column COLUMN_POSITION heading "Col|Pos" format 990 column col heading "Column|Details" format a24 column COLUMN_LENGTH heading "Col|Len" format 990 column GLOBAL_STATS heading "Global|Stats" format a6 column USER_STATS heading "User|Stats" format a6 column SAMPLE_SIZE heading "Sample|Size" format 9,999,990 column to_char(t.last_analyzed,'MM-DD-YYYY') heading "Date|MM-DD-YYYY" format a10 prompt prompt *********** prompt Table Level prompt *********** prompt select TABLE_NAME, NUM_ROWS, BLOCKS, EMPTY_BLOCKS, AVG_SPACE, CHAIN_CNT, AVG_ROW_LEN, GLOBAL_STATS, USER_STATS, SAMPLE_SIZE, to_char(t.last_analyzed,'MM-DD-YYYY') from dba_tables t where owner = upper(nvl('&&Owner',user)) and table_name = upper('&&Table_name') / select COLUMN_NAME, decode(t.DATA_TYPE, 'NUMBER',t.DATA_TYPE||'('|| decode(t.DATA_PRECISION, null,t.DATA_LENGTH||')', t.DATA_PRECISION||','||t.DATA_SCALE||')'), 'DATE',t.DATA_TYPE, 'LONG',t.DATA_TYPE, 'LONG RAW',t.DATA_TYPE, 'ROWID',t.DATA_TYPE, 'MLSLABEL',t.DATA_TYPE, t.DATA_TYPE||'('||t.DATA_LENGTH||')') ||' '|| decode(t.nullable, 'N','NOT NULL', 'n','NOT NULL', NULL) col, NUM_DISTINCT, DENSITY, NUM_BUCKETS, NUM_NULLS, GLOBAL_STATS, USER_STATS, SAMPLE_SIZE, to_char(t.last_analyzed,'MM-DD-YYYY') from dba_tab_columns t where table_name = upper('&Table_name') and owner = upper(nvl('&Owner',user)) / select INDEX_NAME, UNIQUENESS, BLEVEL BLev, LEAF_BLOCKS, DISTINCT_KEYS, NUM_ROWS, AVG_LEAF_BLOCKS_PER_KEY, AVG_DATA_BLOCKS_PER_KEY, CLUSTERING_FACTOR, GLOBAL_STATS, USER_STATS, SAMPLE_SIZE, to_char(t.last_analyzed,'MM-DD-YYYY') from dba_indexes t where table_name = upper('&Table_name') and table_owner = upper(nvl('&Owner',user)) / break on index_name select i.INDEX_NAME, i.COLUMN_NAME, i.COLUMN_POSITION, decode(t.DATA_TYPE, 'NUMBER',t.DATA_TYPE||'('|| decode(t.DATA_PRECISION, null,t.DATA_LENGTH||')', t.DATA_PRECISION||','||t.DATA_SCALE||')'), 'DATE',t.DATA_TYPE, 'LONG',t.DATA_TYPE, 'LONG RAW',t.DATA_TYPE, 'ROWID',t.DATA_TYPE, 'MLSLABEL',t.DATA_TYPE, t.DATA_TYPE||'('||t.DATA_LENGTH||')') ||' '|| decode(t.nullable, 'N','NOT NULL', 'n','NOT NULL', NULL) col from dba_ind_columns i, dba_tab_columns t where i.table_name = upper('&Table_name') and owner = upper(nvl('&Owner',user)) and i.table_name = t.table_name and i.column_name = t.column_name order by index_name,column_position / prompt prompt *************** prompt Partition Level prompt *************** select PARTITION_NAME, NUM_ROWS, BLOCKS, EMPTY_BLOCKS, AVG_SPACE, CHAIN_CNT, AVG_ROW_LEN, GLOBAL_STATS, USER_STATS, SAMPLE_SIZE, to_char(t.last_analyzed,'MM-DD-YYYY') from dba_tab_partitions t where table_owner = upper(nvl('&&Owner',user)) and table_name = upper('&&Table_name') order by partition_position / break on partition_name select PARTITION_NAME, COLUMN_NAME, NUM_DISTINCT, DENSITY, NUM_BUCKETS, NUM_NULLS, GLOBAL_STATS, USER_STATS, SAMPLE_SIZE, to_char(t.last_analyzed,'MM-DD-YYYY') from dba_PART_COL_STATISTICS t where table_name = upper('&Table_name') and owner = upper(nvl('&Owner',user)) / break on partition_name select t.INDEX_NAME, t.PARTITION_NAME, t.BLEVEL BLev, t.LEAF_BLOCKS, t.DISTINCT_KEYS, t.NUM_ROWS, t.AVG_LEAF_BLOCKS_PER_KEY, t.AVG_DATA_BLOCKS_PER_KEY, t.CLUSTERING_FACTOR, t.GLOBAL_STATS, t.USER_STATS, t.SAMPLE_SIZE, to_char(t.last_analyzed,'MM-DD-YYYY') from dba_ind_partitions t, dba_indexes i where i.table_name = upper('&Table_name') and i.table_owner = upper(nvl('&Owner',user)) and i.owner = t.index_owner and i.index_name=t.index_name / prompt prompt *************** prompt SubPartition Level prompt *************** select PARTITION_NAME, SUBPARTITION_NAME, NUM_ROWS, BLOCKS, EMPTY_BLOCKS, AVG_SPACE, CHAIN_CNT, AVG_ROW_LEN, GLOBAL_STATS, USER_STATS, SAMPLE_SIZE, to_char(t.last_analyzed,'MM-DD-YYYY') from dba_tab_subpartitions t where table_owner = upper(nvl('&&Owner',user)) and table_name = upper('&&Table_name') order by SUBPARTITION_POSITION / break on partition_name select p.PARTITION_NAME, t.SUBPARTITION_NAME, t.COLUMN_NAME, t.NUM_DISTINCT, t.DENSITY, t.NUM_BUCKETS, t.NUM_NULLS, t.GLOBAL_STATS, t.USER_STATS, t.SAMPLE_SIZE, to_char(t.last_analyzed,'MM-DD-YYYY') from dba_SUBPART_COL_STATISTICS t, dba_tab_subpartitions p where t.table_name = upper('&Table_name') and t.owner = upper(nvl('&Owner',user)) and t.subpartition_name = p.subpartition_name and t.owner = p.table_owner and t.table_name=p.table_name / break on partition_name select t.INDEX_NAME, t.PARTITION_NAME, t.SUBPARTITION_NAME, t.BLEVEL BLev, t.LEAF_BLOCKS, t.DISTINCT_KEYS, t.NUM_ROWS, t.AVG_LEAF_BLOCKS_PER_KEY, t.AVG_DATA_BLOCKS_PER_KEY, t.CLUSTERING_FACTOR, t.GLOBAL_STATS, t.USER_STATS, t.SAMPLE_SIZE, to_char(t.last_analyzed,'MM-DD-YYYY') from dba_ind_subpartitions t, dba_indexes i where i.table_name = upper('&Table_name') and i.table_owner = upper(nvl('&Owner',user)) and i.owner = t.index_owner and i.index_name=t.index_name / clear breaks set echo on | |
Sample Output | |
*********** Table Level *********** Table Number Empty Average Chain Average Global User Sample Date Name of Rows Blocks Blocks Space Count Row Len Stats Stats Size MM-DD-YYYY --------------- ---------- -------- -------- ------- ----- ------- ------ ------ ---------- ---------- T1 5,000 20 0 0 0 9 YES NO 5,000 06-30-2003 Column Column Distinct Number Global User Sample Date Name Details Values Density Buckets NUM_NULLS Stats Stats Size MM-DD-YYYY ------------------------- ------------------------ -------- ------- ------- ---------- ------ ------ ---------- ---------- T1C1 NUMBER(22) 5,000 0 1 0 YES NO 5,000 06-30-2003 T1C2 NUMBER(22) 7 0 1 0 YES NO 5,000 06-30-2003 T1C3 NUMBER(22) 8 0 1 0 YES NO 5,000 06-30-2003 B Average Average Index Tree Leaf Distinct Number Leaf Blocks Data Blocks Cluster Global User Sample Date Name Unique Level Blks Keys of Rows Per Key Per Key Factor Stats Stats Size MM-DD-YYYY --------------- --------- ----- ---- ---------- ---------- ----------- ----------- -------- ------ ------ ---------- ---------- UN_T1 NONUNIQUE 1 12 5,000 5,000 1 1 12 YES NO 5,000 06-30-2003 Index Column Col Column Name Name Pos Details --------------- ------------------------- ---- ------------------------ UN_T1 T1C1 1 NUMBER(22) *************** Partition Level *************** Partition Number Empty Average Chain Average Global User Sample Date Name of Rows Blocks Blocks Space Count Row Len Stats Stats Size MM-DD-YYYY --------------- ---------- -------- -------- ------- ----- ------- ------ ------ ---------- ---------- Q1 2,144 10 0 0 0 9 YES NO 2,144 06-30-2003 Q2 2,856 10 0 0 0 9 YES NO 2,856 06-30-2003 Partition Column Distinct Number Global User Sample Date Name Name Values Density Buckets NUM_NULLS Stats Stats Size MM-DD-YYYY --------------- ------------------------- -------- ------- ------- ---------- ------ ------ ---------- ---------- Q1 T1C1 2,144 0 1 0 YES NO 2,144 06-30-2003 T1C2 3 0 1 0 YES NO 2,144 06-30-2003 T1C3 8 0 1 0 YES NO 2,144 06-30-2003 Q2 T1C1 2,856 0 1 0 YES NO 2,856 06-30-2003 T1C2 4 0 1 0 YES NO 2,856 06-30-2003 T1C3 8 0 1 0 YES NO 2,856 06-30-2003 B Average Average Index Partition Tree Leaf Distinct Number Leaf Blocks Data Blocks Cluster Global User Sample Date Name Name Level Blks Keys of Rows Per Key Per Key Factor Stats Stats Size MM-DD-YYYY --------------- --------------- ----- ---- ---------- ---------- ----------- ----------- -------- ------ ------ ---------- ---------- UN_T1 Q1 1 12 5,000 5,000 1 1 12 YES NO 5,000 06-30-2003 UN_T1 Q2 1 12 5,000 5,000 1 1 12 YES NO 5,000 06-30-2003 *************** SubPartition Level *************** Partition SubPartition Number Empty Average Chain Average Global User Sample Date Name Name of Rows Blocks Blocks Space Count Row Len Stats Stats Size MM-DD-YYYY --------------- --------------- ---------- -------- -------- ------- ----- ------- ------ ------ ---------- ---------- Q1 SYS_SUBP497 803 5 0 0 0 9 YES NO 803 06-30-2003 Q2 SYS_SUBP499 1,072 5 0 0 0 9 YES NO 1,072 06-30-2003 Q1 SYS_SUBP498 1,341 5 0 0 0 9 YES NO 1,341 06-30-2003 Q2 SYS_SUBP500 1,784 5 0 0 0 9 YES NO 1,784 06-30-2003 Partition SubPartition Column Distinct Number Global User Sample Date Name Name Name Values Density Buckets NUM_NULLS Stats Stats Size MM-DD-YYYY --------------- --------------- ------------------------- -------- ------- ------- ---------- ------ ------ ---------- ---------- Q1 SYS_SUBP497 T1C1 803 0 1 0 YES NO 803 06-30-2003 SYS_SUBP498 T1C1 1,341 0 1 0 YES NO 1,341 06-30-2003 SYS_SUBP497 T1C2 3 0 1 0 YES NO 803 06-30-2003 SYS_SUBP498 T1C2 3 0 1 0 YES NO 1,341 06-30-2003 SYS_SUBP497 T1C3 3 0 1 0 YES NO 803 06-30-2003 SYS_SUBP498 T1C3 5 0 1 0 YES NO 1,341 06-30-2003 Q2 SYS_SUBP499 T1C1 1,072 0 1 0 YES NO 1,072 06-30-2003 SYS_SUBP500 T1C1 1,784 0 1 0 YES NO 1,784 06-30-2003 SYS_SUBP499 T1C2 4 0 1 0 YES NO 1,072 06-30-2003 SYS_SUBP500 T1C2 4 0 1 0 YES NO 1,784 06-30-2003 SYS_SUBP499 T1C3 3 0 1 0 YES NO 1,072 06-30-2003 SYS_SUBP500 T1C3 5 0 1 0 YES NO 1,784 06-30-2003 B Average Average Index Partition SubPartition Tree Leaf Distinct Number Leaf Blocks Data Blocks Cluster Global User Sample Date Name Name Name Level Blks Keys of Rows Per Key Per Key Factor Stats Stats Size MM-DD-YYY --------------- --------------- --------------- ----- ---- ---------- ---------- ----------- ----------- -------- ------ ------ ---------- --------- UN_T1 Q1 SYS_SUBP497 1 2 803 803 1 1 2 YES NO 803 06-30-200 UN_T1 SYS_SUBP498 1 3 1,341 1,341 1 1 3 YES NO 1,341 06-30-200 UN_T1 Q2 SYS_SUBP499 1 3 1,072 1,072 1 1 3 YES NO 1,072 06-30-200 UN_T1 SYS_SUBP500 1 4 1,784 1,784 1 1 4 YES NO 1,784 06-30-200 |
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/82387/viewspace-1016308/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 顯示每個CPU的IDT資訊
- 製作一個表格,顯示班級的學生資訊。
- redis裡顯示key大小的shell指令碼Redis指令碼
- Oracle運維指令碼-收集統計資訊Oracle運維指令碼
- 研究顯示TikTok上的性教育資訊顯示出與傳統教育的差距
- LLIconVersioning-一個可以建立app版本資訊icon的指令碼APP指令碼
- Oracle OCP(07):顯示來自多個表的資料Oracle
- 如何使用Neofetch個性化顯示Linux系統資訊Linux
- 【cbo計算公式】CBO基本概念(一)公式
- 今天寫了一個統計執行sql次數的指令碼SQL指令碼
- anki 模板cloze 多次挖空 點選一次顯示一次 點對應的顯示一個(自帶的會全部顯示出來)
- 用 Linux 命令顯示硬體資訊Linux
- [20220317]補充完善TPT 顯示欄位列的指令碼.txt指令碼
- 顯示驗證的錯誤資訊
- 7 個日常實用的 Shell 拿來就用指令碼例項!指令碼
- 分享一個很好的音樂站
- 在同一頁面顯示多個JavaScript統計圖表JavaScript
- Shell 系統資訊監控指令碼指令碼
- 資料統計指令碼(彙總)指令碼
- Mysql 顯示錶的相關資訊 --命令MySql
- [20221216]建立修改表統計資訊minmaxtab.sql指令碼.txtSQL指令碼
- [20221216]建立修改表統計資訊modtab.sql指令碼.txtSQL指令碼
- 一個用於生成大量mac地址的python指令碼MacPython指令碼
- 讓我們來用php編寫一個搶購商品指令碼PHP指令碼
- 分享兩個實用的shell指令碼指令碼
- 推薦一個很好用的vscode外掛:一個可以給出vuex中store定義資訊的vscode外掛VSCodeVue
- 直播平臺原始碼,各個樣式的訊息通知欄顯示方式原始碼
- MySQL對所有表收集統計資訊(Python 2指令碼)MySqlPython指令碼
- 一對一視訊原始碼,登入時輸入密碼時的顯示密碼按鈕原始碼密碼
- 用Jmeter編寫一個較複雜的測試指令碼JMeter指令碼
- win10系統檢視電腦顯示卡資訊的方法Win10
- 論資訊顯示對我生活的影響
- Linux-top命令顯示的資訊解釋Linux
- 視訊直播系統原始碼,倒數計時顯示,商品秒殺倒數計時原始碼
- 一個方便 LeetCode 複習的指令碼LeetCode指令碼
- python 介紹一個很好用的函式Python函式
- Neofetch:在終端中顯示 Linux 系統資訊Linux
- uname命令顯示系統資訊?linux系統運維命令Linux運維
- Windows Ping的結果顯示每次ping的時間的bat批處理指令碼WindowsBAT指令碼