Skip to content

Instantly share code, notes, and snippets.

@sorra
Created March 18, 2022 06:42
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/f03b092ccbed1b1fcf51e3b965bcc582 to your computer and use it in GitHub Desktop.
Save sorra/f03b092ccbed1b1fcf51e3b965bcc582 to your computer and use it in GitHub Desktop.
Optimized using sequential table scan with limit
QUERY PLAN
------------------------------------------------------------------------------
  Limit  (cost=0.00..13700.25 rows=100 width=915) (actual time=0.013..0.114 rows=100 loops=1)
    ->  Seq Scan on messages  (cost=0.00..4085414.08 rows=29820 width=915) (actual time=0.013..0.106 rows=100 loops=1)
          Filter: ((context -> 'involved_parties'::text) @> '[{"id": 1, "type": 1}]'::jsonb)
  Planning time: 0.058 ms
  Execution time: 0.135 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment