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

From CS Wiki

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;