supabase / splinter

Supabase Postgres Linter
https://supabase.github.io/splinter/
70 stars 6 forks source link

Lint to find duplicate indexes #20

Closed ivasilov closed 3 months ago

ivasilov commented 3 months ago

We can find the same indexes which only differ by index name by using

SELECT array_agg(indexname) AS indexes, replace(indexdef, indexname, '') AS defn
    FROM pg_indexes
GROUP BY defn
  HAVING count(*) > 1;
olirice commented 3 months ago

thats a nice solution for detecting dupes easily

ivasilov commented 3 months ago

This rule is misreporting on tables which have two unrelated indexes to each other. I'm using the Slack clone template to test. Screenshot 2024-04-09 at 12 22 15