Skip to content

Instantly share code, notes, and snippets.

View jlsan92's full-sized avatar
🎯
Focusing

Juan Sanchez jlsan92

🎯
Focusing
View GitHub Profile
@jlsan92
jlsan92 / all-indexes.sql
Created January 14, 2020 12:03 — forked from robertrossmann/all-indexes.sql
Postgres diagnostics
-- List all existing indexes and include some useful info about them (incl. the index's definition)
SELECT
schemaname AS schemaname,
t.relname AS tablename,
ix.relname AS indexname,
regexp_replace(pg_get_indexdef(i.indexrelid), '^[^\(]*\((.*)\)$', '\1') AS columns,
regexp_replace(pg_get_indexdef(i.indexrelid), '.* USING ([^ ]*) \(.*', '\1') AS algorithm,
indisunique AS UNIQUE,
indisprimary AS PRIMARY,