Skip to content

Conversation

@foysalit
Copy link
Contributor

@foysalit foysalit commented Oct 7, 2025

No description provided.

Comment on lines +15 to +16
// Add the trgm extension first
await sql`CREATE EXTENSION IF NOT EXISTS pg_trgm`.execute(db)
Copy link
Collaborator

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.

Comment on lines 4 to 13
// 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)
Copy link
Collaborator

@devinivy devinivy Oct 7, 2025

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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await sql`DROP IF EXISTS pg_trgm CASCADE`.execute(db)
await sql`DROP EXTENSION IF EXISTS pg_trgm CASCADE`.execute(db)

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.

4 participants