✅ 테이블별 I/U/D 건수 측정 쿼리
SELECT
relname AS table_name,
n_tup_ins AS inserts,
n_tup_upd AS updates,
n_tup_del AS deletes,
n_live_tup AS live_rows,
n_dead_tup AS dead_rows,
round((n_tup_upd + n_tup_del)::numeric / NULLIF(n_live_tup, 0), 3) AS churn_ratio
FROM pg_stat_user_tables
ORDER BY churn_ratio DESC NULLS LAST;
컬럼 | 설명 |
n_tup_ins | 총 insert 횟수 |
n_tup_upd | 총 update 횟수 |
n_tup_del | 총 delete 횟수 |
n_live_tup | 현재 살아 있는 row |
n_dead_tup | 현재 vacuum 안된 죽은 row |
churn_ratio | (update + delete) / live_row → 변동성 비율 |
🙌 댓글, 공감, 공유는 큰 힘이 됩니다! 😄
'RDBMS > PostgreSQL, EDB' 카테고리의 다른 글
[PostgreSQL] Citus 기반 Sharding(샤딩) 구축해보기 (0) | 2025.05.30 |
---|---|
[PostgreSQL] Dictionary View 리스트 (0) | 2025.05.27 |
[PostgreSQL] Lock 조회 및 Session Kill 처리 방법 (0) | 2025.05.14 |
[PostgreSQL] Replication Slot 조회 및 삭제 (*WAL File 급증해결) (0) | 2025.05.07 |
[PostgreSQL] PostgreSQL BaseBackup 중 Archive 파일 삭제 시 복구 실패하는 이유 (0) | 2025.04.28 |