explain.depesz.com

PostgreSQL's explain analyze made readable

Result: ZsIZ

Settings
# exclusive inclusive rows x rows loops node
1. 0.555 69.174 ↑ 1.0 1 1

Aggregate (cost=26,836.94..26,836.95 rows=1 width=8) (actual time=69.173..69.174 rows=1 loops=1)

2. 2.319 68.619 ↓ 7.7 3,818 1

Nested Loop Semi Join (cost=0.84..26,835.69 rows=497 width=0) (actual time=0.144..68.619 rows=3,818 loops=1)

3. 0.918 0.918 ↑ 1.0 3,846 1

Index Only Scan using contacts_tags_pkey on contacts_tags (cost=0.29..126.22 rows=3,874 width=13) (actual time=0.034..0.918 rows=3,846 loops=1)

  • Index Cond: (company_id = '\x4c2118ad54397f271b000000'::bytea)
  • Heap Fetches: 1
4. 38.656 65.382 ↑ 1,334.0 1 3,846

Index Only Scan using ix_contacts_tags_associations_company_id_tag_id_contact_id on contacts_tags_associations (cost=0.56..7,491.15 rows=1,334 width=13) (actual time=0.017..0.017 rows=1 loops=3,846)

  • Index Cond: ((company_id = '\x4c2118ad54397f271b000000'::bytea) AND (tag_id = contacts_tags.id))
  • Filter: (alternatives: SubPlan 1 or hashed SubPlan 2)
  • Heap Fetches: 3,818
5.          

SubPlan (for Index Only Scan)

6. 26.726 26.726 ↑ 1.0 1 3,818

Index Scan using contacts_pkey on contacts (cost=0.44..2.77 rows=1 width=0) (actual time=0.007..0.007 rows=1 loops=3,818)

  • Index Cond: ((company_id = (current_setting('nimble.company_id'::text))::bytea) AND (id = contacts_tags_associations.contact_id))
  • Filter: ((company_id = company_id) 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[])) 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[])))
7. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on contacts contacts_1 (cost=305.01..28,038.82 rows=3 width=13) (never executed)

  • 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 = company_id) AND (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[])) 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[])))
8. 0.000 0.000 ↓ 0.0 0

BitmapOr (cost=305.01..305.01 rows=26,473 width=0) (never executed)

9. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on ix_company_id_owner_id (cost=0.00..1.79 rows=10 width=0) (never executed)

  • 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))
10. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on ix_company_rls_permissions (cost=0.00..60.63 rows=5,293 width=0) (never executed)

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

Bitmap Index Scan on ix_company_rls_permissions (cost=0.00..60.64 rows=5,293 width=0) (never executed)

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

Bitmap Index Scan on ix_company_rls_permissions (cost=0.00..60.64 rows=5,293 width=0) (never executed)

  • 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[]))
13. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on ix_company_rls_permissions (cost=0.00..60.64 rows=5,293 width=0) (never executed)

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

Bitmap Index Scan on ix_company_rls_permissions (cost=0.00..60.64 rows=5,293 width=0) (never executed)

  • 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 : 3.209 ms
Execution time : 69.778 ms