Skip to content

Instantly share code, notes, and snippets.

View cihangir's full-sized avatar
💭
Closed sourcing

Cihangir cihangir

💭
Closed sourcing
View GitHub Profile
@cihangir
cihangir / gist:c5a0ff9bca6ab74638e3
Created November 19, 2015 02:18 — forked from jberkus/gist:6b1bcaf7724dfc2a54f3
Finding Unused Indexes
WITH table_scans as (
SELECT relid,
tables.idx_scan + tables.seq_scan as all_scans,
( tables.n_tup_ins + tables.n_tup_upd + tables.n_tup_del ) as writes,
pg_relation_size(relid) as table_size
FROM pg_stat_user_tables as tables
),
all_writes as (
SELECT sum(writes) as total_writes
FROM table_scans