0% found this document useful (0 votes)
88 views

Oracle Histogram Checking

The document contains SQL commands and output related to analyzing histograms and statistics for the TESTING_4_HISTOGRAM_TABLE22 table in the DEMOSS schema. It shows the column distributions, indexed used, execution plans and performance statistics for queries on the STATUS_CD column. The histograms captured for the STATUS_CD column indicate it has a range of values but only 3 distinct values present.

Uploaded by

ashok naga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views

Oracle Histogram Checking

The document contains SQL commands and output related to analyzing histograms and statistics for the TESTING_4_HISTOGRAM_TABLE22 table in the DEMOSS schema. It shows the column distributions, indexed used, execution plans and performance statistics for queries on the STATUS_CD column. The histograms captured for the STATUS_CD column indicate it has a range of values but only 3 distinct values present.

Uploaded by

ashok naga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 6

cat how_to_check_histogram.

txt
SQL> @xplan_sqlid 9kfrgu25mw8t0

SQL_ID 9kfrgu25mw8t0, child number 0


-------------------------------------
SELECT BOOKTID_INTEGRATION_ID, DEM_INST_ID, STATUS_CD,
FROM TESTING_4_HISTOGRAM_TABLE22 where
status_cd = 'NEW'

Plan hash value: 1550447737


-----------------------------------------------------------------------------------
----------------------
| Id | Operation | Name | Rows | Bytes |
Cost (%CPU)| Time |
-----------------------------------------------------------------------------------
----------------------
| 0 | SELECT STATEMENT | | | |
526 (100)| |
|* 1 | TABLE ACCESS STORAGE FULL| TESTING_4_HISTOGRAM_TABLE22 | 133K| 5624K|
526 (5)| 00:00:01 |
-----------------------------------------------------------------------------------
----------------------

Predicate Information (identified by operation id):


---------------------------------------------------
1 - storage("STATUS_CD"='NEW')
filter("STATUS_CD"='NEW')

SQL> @gsql_hist
INST SQL_ID SQL_TEXT DAYS
EXECS BUF_PER_EXE DSK_PER_EXE ROWS_PER_EXE TOT_TIME ELA_PER_EXE SCHEMA
PLAN_HASH LAST_ACTIVE VERCNT BASELINE_PROFILE
---- ------------- -------------------------------------------------------- ------
------------ ----------- ----------- ------------ ---------- ------------
------------- ----------- ----------------- ------ --------------------------------
4 9kfrgu25mw8t0 SELECT BOOKTID_INTEGRATION_ID, DEM_INST_ID, STATUS_CD, P .00
7 57,934 0 188.71 3.2 .4577 LTLWASFIN
1550447737 10/06/22 11:42:06 1 -

SQL> @iftu TESTING_4_HISTOGRAM_TABLE22 DEMOSS


INDEX_NAME TABLE_NAME INDEX_TYPE
UNIQUENESS COLUMN_NAME POSI LAST_ANALYZED DEG BLVL INI PCT_FREE
DISTINCT_KEYS
------------------------------ ---------------------------------- ------------
---------- ------------------------ ----- ---------------- --- ---- ---- ----------
-------------
TESTING_4_HISTOGRAM_TABLE22_N1 DEMOSS.TESTING_4_HISTOGRAM_TABLE22 NORMAL
NONUNIQUE STATUS_CD 1 10/01/22 10:00 1 2 2 10
3
TESTING_4_HISTOGRAM_TABLE22_N2 DEMOSS.TESTING_4_HISTOGRAM_TABLE22 NORMAL
NONUNIQUE DEM_INST_ID 1 10/03/22 10:23 1 2 2 10
754003
TESTING_4_HISTOGRAM_TABLE22_PK DEMOSS.TESTING_4_HISTOGRAM_TABLE22 NORMAL
UNIQUE BOOKTID_INTEGRATION_ID 1 10/01/22 10:00 1 2 2 10
1371783

SQL> @tdetu
TABLE_NAME tblespce PCT_FREE CHAIN_CNT
AVG_ROW_LEN NUM_ROWS INITRAN SIZE_MB LAST_ANALYZED DEGREE PARTITION
COMPRESS_FOR
------------------------------------------ ------------ ---------- ----------
----------- --------------- ------- --------- ---------------- ----------
---------- ---------------
DEMOSS.TESTING_4_HISTOGRAM_TABLE22 DEMOSS_DATA 10 0
212 1,371,783 1 333.9 10/01/22 10:00 1

SQL> @histo
Enter Tablename and Owner as parameters

OWNER TABLE_NAME COLUMN_NAME


COUNT(*)
------------ ---------------------------------- --------------------------------
----------
DEMOSS TESTING_4_HISTOGRAM_TABLE22 BIL2_BOOK_NBR
254
DEMOSS BOOKT_QUALIFIER_CD
2
DEMOSS DEM_INST_ID
2
DEMOSS STATUS_CD
3

11:44:41 SQL>
1 SELECT BOOKTID_INTEGRATION_ID, DEM_INST_ID, STATUS_CD, PRO_NBR_TXT,
2 TRUE_DEBTOR_PPD, TRUE_DEBTOR_COL
3 FROM DEMOSS.TESTING_4_HISTOGRAM_TABLE22
4* where status_cd = 'NEW'
11:44:45 SQL> /

105 rows selected.

Elapsed: 00:00:00.29

Execution Plan
----------------------------------------------------------
Plan hash value: 1550447737
-----------------------------------------------------------------------------------
----------------------
| Id | Operation | Name | Rows | Bytes |
Cost (%CPU)| Time |
-----------------------------------------------------------------------------------
----------------------
| 0 | SELECT STATEMENT | | 133K| 5624K|
526 (5)| 00:00:01 |
|* 1 | TABLE ACCESS STORAGE FULL| TESTING_4_HISTOGRAM_TABLE22 | 133K| 5624K|
526 (5)| 00:00:01 |
-----------------------------------------------------------------------------------
----------------------

Predicate Information (identified by operation id):


---------------------------------------------------

1 - storage("STATUS_CD"='NEW')
filter("STATUS_CD"='NEW')

Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
57988 consistent gets
0 physical reads
236 redo size
6528 bytes sent via SQL*Net to client
594 bytes received via SQL*Net from client
8 SQL*Net roundtrips to/from client
105 rows processed

11:44:45 SQL>
1 SELECT /*+ index(TESTING_4_HISTOGRAM_TABLE22, TESTING_4_HISTOGRAM_TABLE22_N1)
*/ BOOKTID_INTEGRATION_ID, DEM_INST_ID, STATUS_CD, PRO_NBR_TXT,
2 TRUE_DEBTOR_PPD, TRUE_DEBTOR_COL
3 FROM DEMOSS.TESTING_4_HISTOGRAM_TABLE22
4* where status_cd = 'NEW'
11:45:25 SQL> /

221 rows selected.

Elapsed: 00:00:00.13

Execution Plan
----------------------------------------------------------
Plan hash value: 3296785567

-----------------------------------------------------------------------------------
-----------------------------------
| Id | Operation | Name | Rows
| Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------
-----------------------------------
| 0 | SELECT STATEMENT | |
133K| 5624K| 5051 (1)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID BATCHED| TESTING_4_HISTOGRAM_TABLE22 |
133K| 5624K| 5051 (1)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | TESTING_4_HISTOGRAM_TABLE22_N1 |
133K| | 541 (1)| 00:00:01 |
-----------------------------------------------------------------------------------
-----------------------------------

Predicate Information (identified by operation id):


---------------------------------------------------

2 - access("STATUS_CD"='NEW')

Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
1038 consistent gets
515 physical reads
69116 redo size
12874 bytes sent via SQL*Net to client
756 bytes received via SQL*Net from client
16 SQL*Net roundtrips to/from client
221 rows processed

11:48:23 SQL> @colstat.sql TESTING_4_HISTOGRAM_TABLE22 DEMOSS


SQL> col LOW_VALUE for a22
SQL> col HIGH_VALUE for a22
SQL> /

OWNER TABLE_NAME COLUMN_NAME NUM_DISTINCT


LOW_VALUE HIGH_VALUE DENSITY NUM_NULLS NUM_BUCKETS
LAST_ANALYZED SAMPLE_SIZE AVG_COL_LEN HISTOGRAM SCOPE
--------------- ---------------------------- ------------------------ ------------
---------------------- ---------------------- ---------- ---------- -----------
---------------- ----------- ----------- --------------- -------
DEMOSS TESTING_4_HISTOGRAM_TABLE22 BIL2_BOOK_NBR 20788
80 C50A64621A03 .000038 0 254
10/01/22 10:00 5497 7 HYBRID SHARED
DEMOSS BOOKTID_INTEGRATION_ID 1371783
C102 C40226580A 7.2898E-07 0 1
10/01/22 10:00 1371783 6 NONE SHARED
DEMOSS DEM_INST_ID 761856
C70554414F543A36 C708330106513A26 1.3126E-06 0 1
10/01/22 10:00 1371783 9 NONE SHARED
DEMOSS STATUS_CD 3
4E4557 54454D50 3.6449E-07 0 3
10/01/22 10:00 1371783 5 FREQUENCY SHARED

.
.

SQL> ed
1 select
OWNER,TABLE_NAME,COLUMN_NAME,NUM_DISTINCT,LOW_VALUE,HIGH_VALUE,DENSITY,NUM_NULLS,NU
M_BUCKETS,LAST_ANALYZED,SAMPLE_SIZE,AVG_COL_LEN,HISTOGRAM,SCOPE
2 from DBA_TAB_COL_STATISTICS
3 where OWNER like upper('&OWN')
4 and TABLE_NAME like upper('&TAB')
5 and COLUMN_NAME='STATUS_CD'
6* order by 1,2,3,4
SQL> /

OWNER TABLE_NAME COLUMN_NAME NUM_DISTINCT


LOW_VALUE HIGH_VALUE DENSITY NUM_NULLS NUM_BUCKETS
LAST_ANALYZED SAMPLE_SIZE AVG_COL_LEN HISTOGRAM SCOPE
--------------- ---------------------------- ------------------------ ------------
---------------------- ---------------------- ---------- ---------- -----------
---------------- ----------- ----------- --------------- -------
DEMOSS TESTING_4_HISTOGRAM_TABLE22 STATUS_CD 3
4E4557 54454D50 3.6449E-07 0 3
10/01/22 10:00 1371783 5 FREQUENCY SHARED

SQL> set numwidth 20


SQL>
1 SELECT endpoint_number, endpoint_value, endpoint_actual_value
2 FROM DBA_HISTOGRAMS
3 WHERE table_name = 'TESTING_4_HISTOGRAM_TABLE22' and column_name = 'STATUS_CD'
4* ORDER BY endpoint_number
SQL> /

ENDPOINT_NUMBER ENDPOINT_VALUE ENDPOINT_ACTUAL_VALUE


-------------------- -------------------- ----------------------------------------
133951 4.06405534078507E+35
261770 4.32366331314460E+35
1371783 4.37558547706892E+35

SQL> @gather_tab_stats_histo.sql TESTING_4_HISTOGRAM_TABLE22 DEMOSS


SQL> define TAB_NAME=&1
SQL> define OWNER=&2
SQL> begin
2 dbms_stats.gather_table_stats(ownname => '&OWNER', tabname => '&TAB_NAME',
method_opt=>'for all indexed columns size auto', degree => 4);
3 end;
4 /

PL/SQL procedure successfully completed.

SQL>
1 SELECT *
2 FROM DBA_HISTOGRAMS
3 WHERE table_name = 'TESTING_4_HISTOGRAM_TABLE22' and column_name = 'STATUS_CD'
4* ORDER BY endpoint_number
SQL> /

OWNER TABLE_NAME COLUMN_NAME


ENDPOINT_NUMBER ENDPOINT_VALUE ENDPOINT_ACTUAL_VALUE
ENDPOINT_ACTUAL_VALU ENDPOINT_REPEAT_COUNT SCOPE
--------------- ---------------------------- ------------------------
-------------------- -------------------- ----------------------------------------
-------------------- --------------------- -------
DEMOSS TESTING_4_HISTOGRAM_TABLE22 STATUS_CD
103 4.06405534078507E+35
0 SHARED
DEMOSS STATUS_CD
1507662 4.16870410475069E+35
0 SHARED
DEMOSS STATUS_CD
1840883 4.32366331314460E+35
0 SHARED

3 rows selected.

SQL> select STATUS_CD, count(*) from DEMOSS.TESTING_4_HISTOGRAM_TABLE22 group by


STATUS_CD ;

STATUS_C COUNT(*)
-------- --------------------
SENT 333221
PILOT 1507559
NEW 195

SQL> select count(*) from DEMOSS.TESTING_4_HISTOGRAM_TABLE22 ;

COUNT(*)
--------------------
1841029

SQL> @ton2
1 SELECT BOOKTID_INTEGRATION_ID, DEM_INST_ID, STATUS_CD, PRO_NBR_TXT,
2 TRUE_DEBTOR_PPD, TRUE_DEBTOR_COL
3 FROM DEMOSS.TESTING_4_HISTOGRAM_TABLE22
4* where status_cd = 'NEW'
/

89 rows selected.

Elapsed: 00:00:00.02

Execution Plan
----------------------------------------------------------
Plan hash value: 3296785567

-----------------------------------------------------------------------------------
-----------------------------------
| Id | Operation | Name | Rows
| Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------
-----------------------------------
| 0 | SELECT STATEMENT | |
103 | 4532 | 7 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID BATCHED| TESTING_4_HISTOGRAM_TABLE22 |
103 | 4532 | 7 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | TESTING_4_HISTOGRAM_TABLE22_N1 |
103 | | 3 (0)| 00:00:01 |
-----------------------------------------------------------------------------------
-----------------------------------

Predicate Information (identified by operation id):


---------------------------------------------------

2 - access("STATUS_CD"='NEW')

Note
-----
- automatic DOP: Computed Degree of Parallelism is 1 because of parallel
threshold

Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
798 consistent gets
0 physical reads
0 redo size
5697 bytes sent via SQL*Net to client
581 bytes received via SQL*Net from client
7 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
89 rows processed

You might also like