admin管理员组文章数量:1660218
analyze用来收集table和index的统计信息,下面说明一下analyze和statistics的关系。
analyze table test estimate statistics sample 10 percent;
这个语句将收集表和INDEX的信息,但是不会收集column的信息。
analyze index test_pk estimate statistics sample 10 percent;
这个语句收集INDEX信息。
查看table的统计信息
SELECT TABLE_NAME, NUM_ROWS, BLOCKS, AVG_ROW_LEN,
TO_CHAR(LAST_ANALYZED, 'MM/DD/YYYY HH24:MI:SS')
FROM DBA_TABLES
WHERE TABLE_NAME ='TEST';
查看index的统计信息
SELECT INDEX_NAME "NAME", NUM_ROWS, DISTINCT_KEYS "DISTINCT",
LEAF_BLOCKS, CLUSTERING_FACTOR "CF", BLEVEL "LEVEL",
AVG_LEAF_BLOCKS_PER_KEY "ALFBPKEY"
FROM DBA_INDEXES
WHERE INDEX_NAME='TEST_PK';
analyze table test estimate statistics sample 10 percent for table;
只分析表,不包括index和column信息。
analyze table test estimate statistics sample 10 percent for indexes;
分析表和index信息。
analyze table test estimate statistics sample 10 percent for all columns;
分析表和所有的column信息。
analyze table test estimate statistics sample 10 percent for all indexed columms;
分析表和所有的index column信息。
analyze table test estimate statistics sample 10 percent for columns id,name;
分析表和指定的column信息。
ANALYZE TABLE test
COMPUTE STATISTICS FOR COLUMNS country_id SIZE 10;
size用来指定直方图数量。
SELECT COLUMN_NAME, NUM_DISTINCT, NUM_NULLS, NUM_BUCKETS, DENSITY
FROM DBA_TAB_COL_STATISTICS
WHERE TABLE_NAME ='TEST'
ORDER BY COLUMN_NAME;
查看column的统计信息
SELECT column_name,ENDPOINT_NUMBER, ENDPOINT_VALUE
FROM DBA_HISTOGRAMS
WHERE TABLE_NAME ='TEST'
ORDER BY COLUMN_NAME,ENDPOINT_NUMBER;
查看column的直方图信息,只要加了for columns,都会收集直方图信息。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub/371/viewspace-234303/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub/371/viewspace-234303/
本文标签: AnalyzeStatistics
版权声明:本文标题:analyze和statistics 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1729851286a1215447.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论