테이블 인덱스 - DBMS별 확인 방법

From CS Wiki
Revision as of 23:20, 1 September 2022 by Dbeaver (talk | contribs) (새 문서: * 상위 문서: 테이블 인덱스 == PostgreSQL == === 인덱스 확인 === pg_indexes 테이블 활용<blockquote>SELECT * FROM pg_indexes WHERE tablename = 'mytable';</blockquote> === 인덱스 통계 확인 === pg_stat_user_indexes 테이블 활용<syntaxhighlight lang="sql" line="1"> SELECT schemaname AS schema_name, relname AS table_name, indexrelname AS index_name, pg_size_pretty(pg_relation_size(indexrelid::regclass)) AS index_size, idx_scan...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

PostgreSQL[edit | edit source]

인덱스 확인[edit | edit source]

pg_indexes 테이블 활용

SELECT * FROM pg_indexes WHERE tablename = 'mytable';

인덱스 통계 확인[edit | edit source]

pg_stat_user_indexes 테이블 활용

SELECT
    schemaname AS schema_name,
    relname AS table_name,
    indexrelname AS index_name,
    pg_size_pretty(pg_relation_size(indexrelid::regclass)) AS index_size,
    idx_scan,
    idx_tup_read,
    idx_tup_fetch
FROM pg_stat_user_indexes
ORDER BY idx_scan ASC;

인덱스를 타는지 확인[edit | edit source]

EXPLAIN ANALYZE
SELECT * FROM post WHERE test = 'test123';

MySQL[edit | edit source]

SHOW INDEX FROM mytable;