explain.depesz.com

PostgreSQL's explain analyze made readable

Result: X7XI

Settings
# exclusive inclusive rows x rows loops node
1. 7.046 220.105 ↑ 1.0 1 1

Aggregate (cost=3,443.38..3,443.39 rows=1 width=8) (actual time=220.105..220.105 rows=1 loops=1)

2. 192.248 213.059 ↓ 39.7 116,382 1

Bitmap Heap Scan on contacts (cost=58.96..3,436.06 rows=2,929 width=0) (actual time=22.348..213.059 rows=116,382 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=7,579
3. 0.002 20.811 ↓ 0.0 0 1

BitmapOr (cost=58.96..58.96 rows=2,959 width=0) (actual time=20.811..20.811 rows=0 loops=1)

4. 0.032 0.032 ↓ 0.0 0 1

Bitmap Index Scan on ix_company_id_owner_id (cost=0.00..3.42 rows=52 width=0) (actual time=0.032..0.032 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. 20.488 20.488 ↓ 200.3 116,382 1

Bitmap Index Scan on ix_company_rls_permissions (cost=0.00..10.22 rows=581 width=0) (actual time=20.488..20.488 rows=116,382 loops=1)

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

Bitmap Index Scan on ix_company_rls_permissions (cost=0.00..10.23 rows=581 width=0) (actual time=0.098..0.098 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.072 0.072 ↓ 0.0 0 1

Bitmap Index Scan on ix_company_rls_permissions (cost=0.00..10.23 rows=581 width=0) (actual time=0.072..0.072 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.048 0.048 ↓ 0.0 0 1

Bitmap Index Scan on ix_company_rls_permissions (cost=0.00..10.23 rows=581 width=0) (actual time=0.048..0.048 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.071 0.071 ↓ 0.0 0 1

Bitmap Index Scan on ix_company_rls_permissions (cost=0.00..10.23 rows=581 width=0) (actual time=0.070..0.071 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.769 ms
Execution time : 220.794 ms