explain.depesz.com

PostgreSQL's explain analyze made readable

Result: pYA5

Settings
# exclusive inclusive rows x rows loops node
1. 67.173 1,993.151 ↑ 1.0 1 1

Aggregate (cost=26,645.77..26,645.78 rows=1 width=8) (actual time=1,993.151..1,993.151 rows=1 loops=1)

2. 1,771.349 1,925.978 ↓ 40.0 1,052,168 1

Bitmap Heap Scan on contacts (cost=342.23..26,579.99 rows=26,315 width=0) (actual time=164.869..1,925.978 rows=1,052,168 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=49,782
3. 0.000 154.629 ↓ 0.0 0 1

BitmapOr (cost=342.23..342.23 rows=26,582 width=0) (actual time=154.629..154.629 rows=0 loops=1)

4. 0.021 0.021 ↓ 0.0 0 1

Bitmap Index Scan on ix_company_id_owner_id (cost=0.00..5.10 rows=123 width=0) (actual time=0.021..0.021 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))
5. 154.326 154.326 ↓ 198.8 1,052,168 1

Bitmap Index Scan on ix_company_rls_permissions (cost=0.00..59.53 rows=5,292 width=0) (actual time=154.326..154.326 rows=1,052,168 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..59.53 rows=5,292 width=0) (actual time=0.078..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.095 0.095 ↓ 0.0 0 1

Bitmap Index Scan on ix_company_rls_permissions (cost=0.00..59.54 rows=5,292 width=0) (actual time=0.095..0.095 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.054 0.054 ↓ 0.0 0 1

Bitmap Index Scan on ix_company_rls_permissions (cost=0.00..59.53 rows=5,292 width=0) (actual time=0.054..0.054 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.054 0.054 ↓ 0.0 0 1

Bitmap Index Scan on ix_company_rls_permissions (cost=0.00..59.54 rows=5,292 width=0) (actual time=0.054..0.054 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.544 ms
Execution time : 1,994.096 ms