23 Aralık 2022 Cuma

PG_STAT_ALL_INDEXES Sistem Tablosu

seq_scan Alanı
Örnek
Açıklaması şöyle
Suppose you had a database with many indexes and wanted to monitor how well they were being used. You can use the number of times the index scan is against sequential scan pg_stat_statements
Şöyle yaparız
SELECT indexrelname, idx_scan, seq_scan
FROM pg_stat_all_indexes ORDER BY (idx_scan + seq_scan) DESC LIMIT 10;
idx_scan Alanı
Örnek
Kullanılmayan indeksleri bulmak için şöyle yaparız
SELECT
  relname,
  indexrelname,
  idx_scan,
  idx_tup_read,
  idx_tup_fetch,
  pg_size_pretty(pg_relation_size(indexrelname::regclass)) as size
FROM
pg_stat_all_indexes
WHERE
  schemaname = 'public'
  and indexrelname not like 'pg_toast_%'
  and idx_scan = 0
  and idx_tup_read = 0
  and idx_tup_fetch = 0
  and indexrelname != 'SequelizeData_pkey'
ORDER BY
  pg_relation_size(indexrelname::regclass) desc;

Hiç yorum yok:

Yorum Gönder