Skip to content

Instantly share code, notes, and snippets.

@sorra
Created March 18, 2022 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sorra/ed7cf7611880af0b8b6137c1d6e03b6f to your computer and use it in GitHub Desktop.
Save sorra/ed7cf7611880af0b8b6137c1d6e03b6f to your computer and use it in GitHub Desktop.
Unoptimized using the inefficient GIN index
QUERY PLAN
------------------------------------------------------------------------------
  Limit  (cost=2027.11..2399.74 rows=100 width=915) (actual time=6489.987..6490.102 rows=100 loops=1)
   ->  Bitmap Heap Scan on messages  (cost=2027.11..113145.85 rows=29820 width=915) (actual time=6489.986..6490.093 rows=100 loops=1)
         Recheck Cond: (context @> '{"involved_parties": [{"id": 1, "type": 1}]}'::jsonb)
         Heap Blocks: lossy=10
         ->  Bitmap Index Scan on index_messages_on_context  (cost=0.00..2019.65 rows=29820 width=0) (actual time=6477.838..6477.839 rows="millions(confidential number)" loops=1)
               Index Cond: (context @> '{"involved_parties": [{"id": 1, "type": 1}]}'::jsonb)
 Planning time: 0.076 ms
 Execution time: 6490.920 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment