explain.depesz.com

PostgreSQL's explain analyze made readable

Result: ChKm : RLS with ACL in table on pg@10.4, 1000 users

Settings

Optimization path:

# exclusive inclusive rows x rows loops node
1. 0.132 156.230 ↑ 1.0 1 1

Aggregate (cost=36,769,049.67..36,769,049.68 rows=1 width=8) (actual time=156.230..156.230 rows=1 loops=1)

2. 152.380 156.098 ↑ 322.4 1,551 1

Seq Scan on items (cost=0.00..36,767,799.67 rows=500,000 width=0) (actual time=4.118..156.098 rows=1,551 loops=1)

  • Filter: (public OR (alternatives: SubPlan 1 or hashed SubPlan 2))
  • Rows Removed by Filter: 998,449
3.          

SubPlan (for Seq Scan)

4. 0.000 0.000 ↓ 0.0 0

Index Scan using permissions_item_id_idx on permissions (cost=0.43..36.75 rows=1 width=0) (never executed)

  • Index Cond: (item_id = items.id)
  • Filter: (user_or_group_id = ANY ((regexp_split_to_array(current_setting('jwt.claims.role'::text), ','::text))::uuid[]))
5. 0.225 3.718 ↑ 3.5 1,551 1

Bitmap Heap Scan on permissions permissions_1 (cost=166.11..15,882.60 rows=5,387 width=16) (actual time=3.527..3.718 rows=1,551 loops=1)

  • Recheck Cond: (user_or_group_id = ANY ((regexp_split_to_array(current_setting('jwt.claims.role'::text), ','::text))::uuid[]))
  • Heap Blocks: exact=14
6. 3.493 3.493 ↑ 3.5 1,551 1

Bitmap Index Scan on permissions_user_or_group_id_idx (cost=0.00..164.76 rows=5,387 width=0) (actual time=3.493..3.493 rows=1,551 loops=1)

  • Index Cond: (user_or_group_id = ANY ((regexp_split_to_array(current_setting('jwt.claims.role'::text), ','::text))::uuid[]))
Planning time : 2.227 ms
Execution time : 156.302 ms