explain.depesz.com

PostgreSQL's explain analyze made readable

Result: XMPu

Settings
# exclusive inclusive rows x rows loops node
1. 0.425 276.131 ↑ 1.0 1 1

Aggregate (cost=10,196.07..10,196.08 rows=1 width=8) (actual time=276.130..276.131 rows=1 loops=1)

2. 0.356 275.706 ↓ 454.5 5,000 1

Result (cost=5,682.88..10,196.04 rows=11 width=0) (actual time=87.010..275.706 rows=5,000 loops=1)

  • One-Time Filter: ((current_setting('nimble.company_id'::text))::bytea = '\x4d670aba143e3287b9d4427a'::bytea)
3. 15.534 275.350 ↓ 454.5 5,000 1

Hash Semi Join (cost=5,682.88..10,196.04 rows=11 width=0) (actual time=87.008..275.350 rows=5,000 loops=1)

  • Hash Cond: (contacts.id = contacts_1.id)
4. 174.364 205.514 ↓ 29.4 116,382 1

Bitmap Heap Scan on contacts (cost=530.57..5,033.22 rows=3,956 width=13) (actual time=32.635..205.514 rows=116,382 loops=1)

  • Recheck Cond: (((company_id = '\x4d670aba143e3287b9d4427a'::bytea) AND (owner_id = (current_setting('nimble.user_id'::text))::bytea)) OR ((company_id = '\x4d670aba143e3287b9d4427a'::bytea) AND (read_for_users && '{""\\x00""}'::bytea[])) OR ((company_id = '\x4d670aba143e3287b9d4427a'::bytea) AND (read_for_users && ARRAY[(current_setting('nimble.user_id'::text))::bytea])) OR ((company_id = '\x4d670aba143e3287b9d4427a'::bytea) AND (read_for_groups && (string_to_array(current_setting('nimble.group_ids'::text), ','::text))::bytea[])) OR ((company_id = '\x4d670aba143e3287b9d4427a'::bytea) AND (edit_for_users && ARRAY[(current_setting('nimble.user_id'::text))::bytea])) OR ((company_id = '\x4d670aba143e3287b9d4427a'::bytea) AND (edit_for_groups && (string_to_array(current_setting('nimble.group_ids'::text), ','::text))::bytea[])))
  • Filter: ((owner_id = (current_setting('nimble.user_id'::text))::bytea) OR (read_for_users && '{""\\x00""}'::bytea[]) OR (read_for_users && ARRAY[(current_setting('nimble.user_id'::text))::bytea]) OR (read_for_groups && (string_to_array(current_setting('nimble.group_ids'::text), ','::text))::bytea[]) OR (edit_for_users && ARRAY[(current_setting('nimble.user_id'::text))::bytea]) OR (edit_for_groups && (string_to_array(current_setting('nimble.group_ids'::text), ','::text))::bytea[]))
  • Heap Blocks: exact=7,587
5. 0.003 31.150 ↓ 0.0 0 1

BitmapOr (cost=530.57..530.57 rows=4,004 width=0) (actual time=31.150..31.150 rows=0 loops=1)

6. 0.015 0.015 ↓ 0.0 0 1

Bitmap Index Scan on ix_company_id_owner_id (cost=0.00..17.08 rows=552 width=0) (actual time=0.015..0.015 rows=0 loops=1)

  • Index Cond: ((company_id = '\x4d670aba143e3287b9d4427a'::bytea) AND (owner_id = (current_setting('nimble.user_id'::text))::bytea))
7. 26.127 26.127 ↓ 171.5 118,342 1

Bitmap Index Scan on ix_rls_permissions (cost=0.00..101.50 rows=690 width=0) (actual time=26.127..26.127 rows=118,342 loops=1)

  • Index Cond: ((company_id = '\x4d670aba143e3287b9d4427a'::bytea) AND (read_for_users && '{""\\x00""}'::bytea[]))
8. 1.122 1.122 ↓ 0.0 0 1

Bitmap Index Scan on ix_rls_permissions (cost=0.00..101.51 rows=690 width=0) (actual time=1.122..1.122 rows=0 loops=1)

  • Index Cond: ((company_id = '\x4d670aba143e3287b9d4427a'::bytea) AND (read_for_users && ARRAY[(current_setting('nimble.user_id'::text))::bytea]))
9. 1.134 1.134 ↓ 0.0 0 1

Bitmap Index Scan on ix_rls_permissions (cost=0.00..101.51 rows=690 width=0) (actual time=1.134..1.134 rows=0 loops=1)

  • Index Cond: ((company_id = '\x4d670aba143e3287b9d4427a'::bytea) AND (read_for_groups && (string_to_array(current_setting('nimble.group_ids'::text), ','::text))::bytea[]))
10. 1.442 1.442 ↓ 0.0 0 1

Bitmap Index Scan on ix_rls_permissions (cost=0.00..101.51 rows=690 width=0) (actual time=1.441..1.442 rows=0 loops=1)

  • Index Cond: ((company_id = '\x4d670aba143e3287b9d4427a'::bytea) AND (edit_for_users && ARRAY[(current_setting('nimble.user_id'::text))::bytea]))
11. 1.307 1.307 ↓ 0.0 0 1

Bitmap Index Scan on ix_rls_permissions (cost=0.00..101.51 rows=690 width=0) (actual time=1.307..1.307 rows=0 loops=1)

  • Index Cond: ((company_id = '\x4d670aba143e3287b9d4427a'::bytea) AND (edit_for_groups && (string_to_array(current_setting('nimble.group_ids'::text), ','::text))::bytea[]))
12. 1.267 54.302 ↓ 1.3 5,000 1

Hash (cost=5,102.86..5,102.86 rows=3,956 width=13) (actual time=54.302..54.302 rows=5,000 loops=1)

  • Buckets: 8,192 (originally 4096) Batches: 1 (originally 1) Memory Usage: 284kB
13. 0.379 53.035 ↓ 1.3 5,000 1

Limit (cost=530.61..5,063.30 rows=3,956 width=13) (actual time=37.605..53.035 rows=5,000 loops=1)

14. 16.587 52.656 ↓ 1.3 5,000 1

Bitmap Heap Scan on contacts contacts_1 (cost=530.61..5,063.30 rows=3,956 width=13) (actual time=37.602..52.656 rows=5,000 loops=1)

  • Recheck Cond: (((company_id = (current_setting('nimble.company_id'::text))::bytea) AND (owner_id = (current_setting('nimble.user_id'::text))::bytea)) OR ((company_id = (current_setting('nimble.company_id'::text))::bytea) AND (read_for_users && '{""\\x00""}'::bytea[])) OR ((company_id = (current_setting('nimble.company_id'::text))::bytea) AND (read_for_users && ARRAY[(current_setting('nimble.user_id'::text))::bytea])) OR ((company_id = (current_setting('nimble.company_id'::text))::bytea) AND (read_for_groups && (string_to_array(current_setting('nimble.group_ids'::text), ','::text))::bytea[])) OR ((company_id = (current_setting('nimble.company_id'::text))::bytea) AND (edit_for_users && ARRAY[(current_setting('nimble.user_id'::text))::bytea])) OR ((company_id = (current_setting('nimble.company_id'::text))::bytea) AND (edit_for_groups && (string_to_array(current_setting('nimble.group_ids'::text), ','::text))::bytea[])))
  • Filter: ((company_id = (current_setting('nimble.company_id'::text))::bytea) AND ((owner_id = (current_setting('nimble.user_id'::text))::bytea) OR (read_for_users && '{""\\x00""}'::bytea[]) OR (read_for_users && ARRAY[(current_setting('nimble.user_id'::text))::bytea]) OR (read_for_groups && (string_to_array(current_setting('nimble.group_ids'::text), ','::text))::bytea[]) OR (edit_for_users && ARRAY[(current_setting('nimble.user_id'::text))::bytea]) OR (edit_for_groups && (string_to_array(current_setting('nimble.group_ids'::text), ','::text))::bytea[])))
  • Heap Blocks: exact=2,361
15. 0.003 36.069 ↓ 0.0 0 1

BitmapOr (cost=530.61..530.61 rows=4,004 width=0) (actual time=36.069..36.069 rows=0 loops=1)

16. 0.054 0.054 ↓ 0.0 0 1

Bitmap Index Scan on ix_company_id_owner_id (cost=0.00..17.09 rows=552 width=0) (actual time=0.054..0.054 rows=0 loops=1)

  • Index Cond: ((company_id = (current_setting('nimble.company_id'::text))::bytea) AND (owner_id = (current_setting('nimble.user_id'::text))::bytea))
17. 28.357 28.357 ↓ 171.5 118,342 1

Bitmap Index Scan on ix_rls_permissions (cost=0.00..101.51 rows=690 width=0) (actual time=28.356..28.357 rows=118,342 loops=1)

  • Index Cond: ((company_id = (current_setting('nimble.company_id'::text))::bytea) AND (read_for_users && '{""\\x00""}'::bytea[]))
18. 2.456 2.456 ↓ 0.0 0 1

Bitmap Index Scan on ix_rls_permissions (cost=0.00..101.52 rows=690 width=0) (actual time=2.456..2.456 rows=0 loops=1)

  • Index Cond: ((company_id = (current_setting('nimble.company_id'::text))::bytea) AND (read_for_users && ARRAY[(current_setting('nimble.user_id'::text))::bytea]))
19. 2.397 2.397 ↓ 0.0 0 1

Bitmap Index Scan on ix_rls_permissions (cost=0.00..101.52 rows=690 width=0) (actual time=2.396..2.397 rows=0 loops=1)

  • Index Cond: ((company_id = (current_setting('nimble.company_id'::text))::bytea) AND (read_for_groups && (string_to_array(current_setting('nimble.group_ids'::text), ','::text))::bytea[]))
20. 1.615 1.615 ↓ 0.0 0 1

Bitmap Index Scan on ix_rls_permissions (cost=0.00..101.52 rows=690 width=0) (actual time=1.615..1.615 rows=0 loops=1)

  • Index Cond: ((company_id = (current_setting('nimble.company_id'::text))::bytea) AND (edit_for_users && ARRAY[(current_setting('nimble.user_id'::text))::bytea]))
21. 1.187 1.187 ↓ 0.0 0 1

Bitmap Index Scan on ix_rls_permissions (cost=0.00..101.52 rows=690 width=0) (actual time=1.187..1.187 rows=0 loops=1)

  • Index Cond: ((company_id = (current_setting('nimble.company_id'::text))::bytea) AND (edit_for_groups && (string_to_array(current_setting('nimble.group_ids'::text), ','::text))::bytea[]))
Planning time : 0.909 ms
Execution time : 277.201 ms