explain.depesz.com

PostgreSQL's explain analyze made readable

Result: txIT

Settings
# exclusive inclusive rows x rows loops node
1. 2.708 95.962 ↑ 1.0 1 1

Aggregate (cost=3,317.32..3,317.33 rows=1 width=8) (actual time=95.961..95.962 rows=1 loops=1)

2. 81.484 93.254 ↓ 17.7 50,000 1

Bitmap Heap Scan on contacts (cost=56.57..3,310.27 rows=2,819 width=0) (actual time=12.259..93.254 rows=50,000 loops=1)

  • Recheck Cond: (((company_id = (current_setting('nimble.company_id'::text))::bytea) AND (owner_id IS NOT NULL) 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 IS NOT NULL) 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=3,978
3. 0.006 11.770 ↓ 0.0 0 1

BitmapOr (cost=56.57..56.57 rows=2,848 width=0) (actual time=11.770..11.770 rows=0 loops=1)

4. 0.023 0.023 ↓ 0.0 0 1

Bitmap Index Scan on ix_company_id_owner_id (cost=0.00..2.24 rows=46 width=0) (actual time=0.023..0.023 rows=0 loops=1)

  • Index Cond: ((company_id = (current_setting('nimble.company_id'::text))::bytea) AND (owner_id IS NOT NULL) AND (owner_id = (current_setting('nimble.user_id'::text))::bytea))
5. 11.636 11.636 ↓ 89.3 50,000 1

Bitmap Index Scan on ix_company_rls_permissions (cost=0.00..10.01 rows=560 width=0) (actual time=11.635..11.636 rows=50,000 loops=1)

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

Bitmap Index Scan on ix_company_rls_permissions (cost=0.00..10.02 rows=560 width=0) (actual time=0.027..0.027 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]))
7. 0.028 0.028 ↓ 0.0 0 1

Bitmap Index Scan on ix_company_rls_permissions (cost=0.00..10.02 rows=560 width=0) (actual time=0.027..0.028 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[]))
8. 0.029 0.029 ↓ 0.0 0 1

Bitmap Index Scan on ix_company_rls_permissions (cost=0.00..10.02 rows=560 width=0) (actual time=0.029..0.029 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]))
9. 0.021 0.021 ↓ 0.0 0 1

Bitmap Index Scan on ix_company_rls_permissions (cost=0.00..10.02 rows=560 width=0) (actual time=0.021..0.021 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.941 ms
Execution time : 99.466 ms