PostgreSQL – Unused Index Script

PostgreSQL de kullanılmayan indexleri bulmak için kullanabileceğiniz güzel bir scriptimi paylaşıyorum arkadaşlar.

SELECT
  PSUI.indexrelid::regclass AS IndexName
  ,PSUI.relid::regclass AS TableName
FROM pg_stat_user_indexes AS PSUI
JOIN pg_index AS PI
    ON PSUI.IndexRelid = PI.IndexRelid
WHERE PSUI.idx_scan = 0
  AND PI.indisunique IS FALSE;

Kolay Gelsin

Leave a Reply

Your email address will not be published. Required fields are marked *