-
Notifications
You must be signed in to change notification settings - Fork 2
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: add missing postgres indexes #3910
Conversation
CREATE INDEX "reconciliation_requests_session_id_idx" on | ||
"public"."reconciliation_requests" using hash ("session_id"); | ||
CREATE INDEX "published_flows_created_at_idx" on | ||
"public"."published_flows" using btree ("created_at"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple notes about this migration:
- Why a mix of
hash
versusbtree
index types?- I'm using
hash
indices when it's a column that is exclusively queried via an equality check (eg session id) andbtree
indices when a) it's a column that is queried via equality or range checks or b) multiple columns are combined into the same index - Postgres docs on this are helpful https://www.postgresql.org/docs/current/indexes-types.html
- I'm using
- I'm adding an index to
published_flows.created_at
because that is how all of our current queries are ordering, but I have not actually checked/compared yet if there's a difference to sort by published flow id (or jogged my memory about why we don't do this already). Even if we swap how we order in the future, an index oncreated_at
should still be useful/hit here when we do date comparisons for reconciliation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may also be worth adding a DESC
in here as we're always searching in this order (docs).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -157,7 +157,7 @@ | |||
definition: | |||
enable_manual: false | |||
insert: | |||
columns: "*" | |||
columns: '*' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is only formatting changes 🌀
Removed vultr server and associated DNS entries |
CREATE INDEX "reconciliation_requests_session_id_idx" on | ||
"public"."reconciliation_requests" using hash ("session_id"); | ||
CREATE INDEX "published_flows_created_at_idx" on | ||
"public"."published_flows" using btree ("created_at"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may also be worth adding a DESC
in here as we're always searching in this order (docs).
Follows on from publishing debugging today: https://opensystemslab.slack.com/archives/C01E3AC0C03/p1730715895034839
Approached this from two directions:
where
params)select * from pg_stat_user_indexes where schemaname = 'public' order by idx_scan asc;
for this oneWish that
published_flows
&flows
would have come up higher on the "need to improve" checks, but the truth is they didn't !