Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 27759

How to see the unused indexes for a query - response (1) by Alison

$
0
0
You can see which indexes were used by looking at the EXPLAIN. To see when an index was last used, you can run the following query. It is not speific to a query. SELECT DatabaseName , TableName , IndexName , ColumnName , IndexType, CASE IndexType WHEN 'P' THEN 'Nonpartitioned Primary' WHEN 'S' THEN 'Secondary' WHEN 'K' THEN 'Primary Key' WHEN 'U' THEN 'Unique Constraint' WHEN 'Q' THEN 'Partitioned Primary' WHEN 'V' THEN 'Value Ordered Secondary' WHEN 'J' THEN 'Join Index' WHEN 'N' THEN 'Hash Index' WHEN 'O' THEN 'Value Ordered (All) covering secondary' WHEN 'H' THEN 'Hash Ordered (All) covering secondary' WHEN 'I' THEN 'Ordering column of composite secondary' WHEN 'M' THEN 'Multi-Column statistics' WHEN 'D' THEN 'Derived column partition statistics' ELSE IndexType END (TITLE 'Type') ,UniqueFlag AS "Unique" ,IndexNumber ,ColumnPosition ,AccessCount ,LastAccessTimeStamp AS "Last Access" ,CreatorName ,CreateTimeStamp ,LastAlterName ,LastAlterTimeStamp FROM DBC.IndicesV WHERE TRIM(ReplaceWithYourDataBaseName) LIKE 'PD' AND IndexType NOT IN ('1','2','I','M','D') ORDER BY DatabaseName, TableName, IndexNumber, ColumnPosition;

Viewing all articles
Browse latest Browse all 27759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>