Subscribe to Posts by Email

Subscriber Count

    701

Disclaimer

All information is offered in good faith and in the hope that it may be of use for educational purpose and for Database community purpose, but is not guaranteed to be correct, up to date or suitable for any particular purpose. db.geeksinsight.com accepts no liability in respect of this information or its use. This site is independent of and does not represent Oracle Corporation in any way. Oracle does not officially sponsor, approve, or endorse this site or its content and if notify any such I am happy to remove. Product and company names mentioned in this website may be the trademarks of their respective owners and published here for informational purpose only. This is my personal blog. The views expressed on these pages are mine and learnt from other blogs and bloggers and to enhance and support the DBA community and this web blog does not represent the thoughts, intentions, plans or strategies of my current employer nor the Oracle and its affiliates or any other companies. And this website does not offer or take profit for providing these content and this is purely non-profit and for educational purpose only. If you see any issues with Content and copy write issues, I am happy to remove if you notify me. Contact Geek DBA Team, via geeksinsights@gmail.com

Pages

How to determine to collect histograms or not (Even oracle determines by same)

From Oracle 10g, the Oracle SMON (System Monitor) process regularly gathers information on columns that are used in query predicates and updates them automatically into a table named COL_USAGE$ in the SYS schema. Unlike the MON_MOD$ table, also in the SYS schema, which records table-level DML activity such as the number of rows changed by INSERT, DELETE, and UPDATE operations, and exposes them via the DBA_TAB_MODIFICATIONS view, the COL_USAGE$ view is neither documented nor wrapped by a legible view. The column names, however, are very revealing; these are detailed in

Col_usage$ description
Column Name	Description
OBJ#	         Object number. Corresponds directly to the OBJ# column in the SYS.OBJ$ table. You can use this to determine the name of the table containing that column.
INTCOL#	         Column number. Corresponds directly to the COL# column in the SYS.COL$ table. You can use this to determine the name of the column involved.
EQUALITY_PREDS	Number of times this column uses an equality predicate of the form table.column = constant.
EQUIJOIN_PREDS	Number of times this column was used in an equijoin using a predicate of the form table1.column1 = table2.column2.
NONEQUIJOIN_PREDS	Number of times this column was used in an nonequijoin using a predicate of the form table1.column1 != table2.column2.
RANGE_PREDS	Number of times this column was used as a predicate of the form table1.column1 BETWEEN constant1 AND constant2.
LIKE_PREDS	Number of times this column was used as a predicate of the form table1.column1 LIKE like_constant.
NULL_PREDS	Number of times this column was used as a predicate of the form table1.column1 IS NULL.
TIMESTAMP	         The timestamp when the column was last recorded as having been used as a predicate in any query. This is updated by SMON once every 15 minutes.

Using the values in this table, you can determine whether additional indexes and histograms can be created on these columns based on how the columns are referred and by what type of predicates.

For example if that column is involved more in range predicates a histograms creation may helpful and also for a equijoin predicates.

As usual, there are some caveats. Be aware that SMON obtains this information by scanning the library cache in the shared pool and updating this table once every 15 minutes or so. In an active database with memory pressure on the shared pool, this information may be lost. This information may also be lost when the database is shut down unless you invoke the DBMS_STATS.FLUSH_DATABASE_MONITORING_INFO procedure beforehand.

-Thanks
Geek DBA

2 comments to How to determine to collect histograms or not (Even oracle determines by same)