-
Notifications
You must be signed in to change notification settings - Fork 501
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
services/horizon/internal/db2/schema: Remove unnecessary tables and indexes #2419
services/horizon/internal/db2/schema: Remove unnecessary tables and indexes #2419
Conversation
7642617
to
99bfab5
Compare
Out of curiosity, do you have an authoritative source on redundant indexes causing performance problems? I have been looking it up and couldn't find anything. Intuitively, I don't see why Postgres would optimize them out, but maybe that's the case. |
@2opremio I couldn't find anything authoritative except for the "Duplicate indexes" section in https://wiki.postgresql.org/wiki/Index_Maintenance However, I did run a SQL query on the horizon staging db to get index size and usage statistics. Here is the output:
If you look at the pairs ( |
That makes sense. Thanks for the explanation . I wonder why Anyways, LGTM. |
The asset_stats table is not used anymore because it has been replaced by exp_asset_stats. index_history_transactions_on_id is not necessary because it is identical to hs_transaction_by_id index_history_ledgers_on_id is not necessary because it is identical to hs_ledger_by_id asset_by_code is not necessary because there is a compound index history_assets_asset_code_asset_type_asset_issuer_key on `UNIQUE(asset_code, asset_type, asset_issuer)` which can be used on queries involving the `asset_code` column. For the same reason, exp_asset_stats_by_code can also be removed
96daebe
to
c4ad431
Compare
PR Checklist
PR Structure
otherwise).
services/friendbot
, orall
ordoc
if the changes are broad or impact manypackages.
Thoroughness
.md
files, etc... affected by this change). Take a look in the
docs
folder for a given service,like this one.
Release planning
needed with deprecations, added features, breaking changes, and DB schema changes.
semver, or if it's mainly a patch change. The PR is targeted at the next
release branch if it's not a patch change.
What
Close #2405
The asset_stats table is not used anymore because it has been replaced by exp_asset_stats.
index_history_transactions_on_id is not necessary because it is identical to hs_transaction_by_id
index_history_ledgers_on_id is not necessary because it is identical to hs_ledger_by_id
asset_by_code is not necessary because there is a compound index history_assets_asset_code_asset_type_asset_issuer_key
on
UNIQUE(asset_code, asset_type, asset_issuer)
which can be used on queries involving theasset_code
column.for the same reasons, exp_asset_stats_by_code can also be removed
Why
These duplicate indexes don't improve query performance but do inhibit write performance. Removing the indexes will reduce storage and improve database write performance.
Known limitations
N/A