lndhub.go icon indicating copy to clipboard operation
lndhub.go copied to clipboard

fix: remove unused index

Open reneaaron opened this issue 2 years ago • 2 comments
trafficstars

Unused indezes

SELECT
  schemaname || '.' || relname AS table,
  indexrelname AS index,
  pg_size_pretty(pg_relation_size(i.indexrelid)) AS index_size,
  idx_scan as index_scans
FROM pg_stat_user_indexes ui
JOIN pg_index i ON ui.indexrelid = i.indexrelid
WHERE NOT indisunique AND idx_scan < 50 AND pg_relation_size(relid) > 5 * 8192
ORDER BY pg_relation_size(i.indexrelid) / nullif(idx_scan, 0) DESC NULLS FIRST,
pg_relation_size(i.indexrelid) DESC;

reneaaron avatar Feb 06 '23 14:02 reneaaron

Does this index hurt? querying tx entries by user id is still something valuable imo. (at least from an admin point.)

bumi avatar Feb 06 '23 20:02 bumi

It doesn't hurt, but since the index has never been scanned according to the PostgreSQL query above I thought it would make sense to remove it.

Running a query on transaction_entires and filtering by user_id is pretty fast even without an index. (< 1 s)

reneaaron avatar Feb 16 '23 00:02 reneaaron