Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Old query, jsonb:
- QUERY PLAN
- ----------------------------------------------------------------------------------------------------------------------------------
- Nested Loop (cost=0.48..1359.15 rows=2714 width=168) (actual time=0.067..41.844 rows=2476 loops=1)
- -> Seq Scan on users (cost=0.00..40.14 rows=2714 width=309) (actual time=0.019..1.851 rows=2476 loops=1)
- -> Aggregate (cost=0.48..0.48 rows=1 width=32) (actual time=0.015..0.016 rows=1 loops=2476)
- -> Function Scan on jsonb_each_text tmp (cost=0.00..0.48 rows=1 width=32) (actual time=0.013..0.014 rows=1 loops=2476)
- Filter: ((val = 'true'::text) AND (col = ANY ('{premium,pepsi,spawnmason,staff,developer}'::text[])))
- Rows Removed by Filter: 13
- Planning Time: 0.156 ms
- Execution Time: 42.072 ms
- (8 rows)
- Your first suggestion, with VALUES:
- QUERY PLAN
- -------------------------------------------------------------------------------------------------------------------
- Seq Scan on users (cost=0.00..87.64 rows=2714 width=168) (actual time=0.026..7.057 rows=2476 loops=1)
- SubPlan 1
- -> Values Scan on "*VALUES*" (cost=0.00..0.02 rows=2 width=32) (actual time=0.000..0.002 rows=1 loops=2476)
- Filter: column2
- Rows Removed by Filter: 4
- Planning Time: 0.146 ms
- Execution Time: 7.166 ms
- (7 rows)
- Your last suggestion, with string_to_array:
- QUERY PLAN
- --------------------------------------------------------------------------------------------------------
- Seq Scan on users (cost=0.00..42.86 rows=2714 width=168) (actual time=0.021..1.816 rows=2476 loops=1)
- Planning Time: 0.071 ms
- Execution Time: 1.945 ms
- (3 rows)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement