explain.depesz.com

PostgreSQL's explain analyze made readable

Result: gUMI

Settings
# exclusive inclusive rows x rows loops node
1. 0.213 1,019.221 ↑ 1.0 1 1

Aggregate (cost=8,590.59..8,590.60 rows=1 width=8) (actual time=1,019.220..1,019.221 rows=1 loops=1)

2. 0.691 1,019.008 ↓ 6.5 1,041 1

Nested Loop Semi Join (cost=0.84..8,590.18 rows=161 width=0) (actual time=3.249..1,019.008 rows=1,041 loops=1)

3. 0.335 0.335 ↑ 1.0 1,246 1

Index Only Scan using contacts_tags_pkey on contacts_tags (cost=0.29..43.71 rows=1,255 width=13) (actual time=0.021..0.335 rows=1,246 loops=1)

  • Index Cond: (company_id = '\x4d670aba143e3287b9d4427a'::bytea)
  • Heap Fetches: 0
4. 130.442 1,017.982 ↑ 728.0 1 1,246

Index Only Scan using ix_contacts_tags_associations_company_id_tag_id_contact_id on contacts_tags_associations (cost=0.56..4,033.87 rows=728 width=13) (actual time=0.817..0.817 rows=1 loops=1,246)

  • Index Cond: ((company_id = '\x4d670aba143e3287b9d4427a'::bytea) AND (tag_id = contacts_tags.id))
  • Filter: (alternatives: SubPlan 1 or hashed SubPlan 2)
  • Rows Removed by Filter: 70
  • Heap Fetches: 88,754
5.          

SubPlan (for Index Only Scan)

6. 887.540 887.540 ↓ 0.0 0 88,754

Index Scan using contacts_pkey on contacts (cost=0.44..2.71 rows=1 width=0) (actual time=0.010..0.010 rows=0 loops=88,754)

  • 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[])))
  • Rows Removed by Filter: 1
7. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on contacts contacts_1 (cost=68.07..3,253.77 rows=14 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[])))
8. 0.000 0.000 ↓ 0.0 0

BitmapOr (cost=68.07..68.07 rows=2,781 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.68 rows=1 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..13.27 rows=556 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..13.27 rows=556 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..13.28 rows=556 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..13.27 rows=556 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..13.28 rows=556 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 : 1.133 ms
Execution time : 1,019.582 ms