Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove unused index #301

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

fix: remove unused index #301

wants to merge 1 commit into from

Conversation

reneaaron
Copy link
Contributor

@reneaaron reneaaron commented Feb 6, 2023

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;

@bumi
Copy link
Contributor

bumi commented Feb 6, 2023

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

@reneaaron
Copy link
Contributor Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants