Last active
March 17, 2022 08:56
-
-
Save sorra/48bf97796cefa89f3b2124b822fb2705 to your computer and use it in GitHub Desktop.
The slow query on messages table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT messages.* FROM messages | |
WHERE messages.deleted_at IS NULL AND messages.namespace = ? | |
AND ( | |
jsonb_extract_path_text(context, 'topic') IN (?, ?) | |
OR jsonb_extract_path_text(context, 'topic') LIKE ? | |
) | |
AND ( context @> '{"involved_parties":[{"id":1,"type":1}]}'::jsonb ) | |
ORDER BY messages.created_at ASC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment