explain.depesz.com

PostgreSQL's explain analyze made readable

Result: mjNgo

Settings
# exclusive inclusive rows x rows loops node
1. 7.539 237.723 ↑ 1.0 1 1

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

2. 208.293 230.184 ↓ 39.7 116,382 1

Bitmap Heap Scan on contacts (cost=58.96..3,436.06 rows=2,929 width=0) (actual time=23.259..230.184 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 21.891 ↓ 0.0 0 1

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

4. 0.017 0.017 ↓ 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.017..0.017 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. 21.576 21.576 ↓ 200.3 116,382 1

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

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

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

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

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

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