-
Notifications
You must be signed in to change notification settings - Fork 782
⚡ Add better indexes for searching ozone events by comment keyword and batch id #4261
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
base: main
Are you sure you want to change the base?
Conversation
| // Add the trgm extension first | ||
| await sql`CREATE EXTENSION IF NOT EXISTS pg_trgm`.execute(db) |
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.
Just a note that I think this may require superuser access on the database. So would have to check how it will play with the ozone distro and other deployments.
| // Remove the old index for batch id that's not very optimized | ||
| await sql`DROP INDEX IF EXISTS "moderation_event_mod_tool_batch_id_idx"`.execute( | ||
| db, | ||
| ) | ||
| // create the new optimized index for batch id | ||
| await sql` | ||
| CREATE INDEX "moderation_event_batch_created_id_desc_idx" | ||
| ON "moderation_event" ( ("modTool"->'meta'->>'batchId'), "createdAt" DESC, "id" DESC ) | ||
| WHERE ("modTool"->'meta'->>'batchId') IS NOT NULL | ||
| `.execute(db) |
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.
Probably no big deal, but this will create a period where there's no index coverage at all. If that's an issue it could be addressed by creating the new index before dropping the old one.
| `.execute(db) | ||
|
|
||
| await sql`DROP INDEX IF EXISTS "moderation_event_comment_trigram"`.execute(db) | ||
| await sql`DROP IF EXISTS pg_trgm CASCADE`.execute(db) |
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.
| await sql`DROP IF EXISTS pg_trgm CASCADE`.execute(db) | |
| await sql`DROP EXTENSION IF EXISTS pg_trgm CASCADE`.execute(db) |
No description provided.