-
Notifications
You must be signed in to change notification settings - Fork 5
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
Migrations to add indexes and realtime support #59
Migrations to add indexes and realtime support #59
Conversation
Also changes README to reflect this.
Someone is attempting to deploy a commit to a Personal Account owned by @cmnord on Vercel. @cmnord first needs to authorize it. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Can you add more context in the commit message (& copy to PR description)? If I look back at the commit later, I'll ask "why did we make this change?". The reason for this change is that:
|
Also since we don't have a staging Supabase environment, the only testing is unfortunately local. Can you confirm that the migration works (and maybe improves performance?) locally? |
Another real SWE question would be how long the migration takes to run locally if you pulled down a copy of the full db, but I don't think that's (a) going to be an issue with our DB size and (b) really something I know how to handle if it was too long 😛 |
edb877d
to
b2cdea3
Compare
Ok, updated. |
- Postgres doesn't automatically index foreign keys, so we add them manually. - Indexes speed up child-to-parent queries significantly, which may help mitigate timeouts when fetching games, due to the game-category and category-clue joins.
b2cdea3
to
6b0dc13
Compare
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.
Looks good, thank you for addressing the comments!
I'll have to pull the migration to my laptop and run supabase db push
to actually apply the migration, so tests might be wonky for a bit but nothing should break on deployment.
Migration testing results: Before: running with the prod credentials
Clues at 0% is bad!
Many sequential scans on clues, categories, and room_events! Testing migration locallyApplied the migration locally and ran again (unfortunately blowing away my local database):
I upgraded Supabase and this command broke. Not totally sure what's going on here locally. |
Postgres doesn't automatically index foreign keys, so we add them manually. This speeds up child-to-parent queries significantly, which may help mitigate timeout issues.
I have tested the migrations locally, and confirmed they increase use of indexes (from ~50% on the
games
table to ~90%). You can compute statistics about index usage on a local database withnpx supabase inspect db index-usage --db-url postgresql://postgres:postgres@localhost:54322/postgres
.