✅ 테이블별 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 → 변동성 비율

 

 

 

 

🙌 댓글, 공감, 공유는 큰 힘이 됩니다! 😄

 

 

+ Recent posts