explain.depesz.com

PostgreSQL's explain analyze made readable

Result: w8GH

Settings
# exclusive inclusive rows x rows loops node
1. 0.054 1,140.112 ↑ 1,227.9 800 1

Result (cost=0.43..20,425,095.14 rows=982,315 width=92) (actual time=0.151..1,140.112 rows=800 loops=1)

  • One-Time Filter: ((current_setting('nimble.company_id'::text))::bytea = '\x4c2118ad54397f271b000000'::bytea)
2. 1,139.075 1,140.058 ↑ 1,227.9 800 1

Index Scan using contacts_pkey on contacts (cost=0.43..20,425,095.14 rows=982,315 width=92) (actual time=0.149..1,140.058 rows=800 loops=1)

  • Index Cond: (company_id = '\x4c2118ad54397f271b000000'::bytea)
  • Filter: ((alternatives: SubPlan 1 or hashed SubPlan 2) OR (alternatives: SubPlan 3 or hashed SubPlan 4) OR (alternatives: SubPlan 5 or hashed SubPlan 6) OR (alternatives: SubPlan 7 or hashed SubPlan 8))
  • Rows Removed by Filter: 1,051,368
3.          

SubPlan (for Index Scan)

4. 0.000 0.000 ↓ 0.0 0

Index Only Scan using ix_contacts__users_rls_associations on contacts__users_rls_associations (cost=0.29..2.51 rows=1 width=0) (never executed)

  • Index Cond: ((company_id = (current_setting('nimble.company_id'::text))::bytea) AND (role = 'read'::permission_role) AND (user_id = (current_setting('nimble.user_id'::text))::bytea) AND (contact_id = contacts.id))
  • Heap Fetches: 0
5. 0.084 0.084 ↑ 1.0 200 1

Index Only Scan using ix_contacts__users_rls_associations on contacts__users_rls_associations contacts__users_rls_associations_1 (cost=0.29..11.19 rows=200 width=13) (actual time=0.036..0.084 rows=200 loops=1)

  • Index Cond: ((company_id = (current_setting('nimble.company_id'::text))::bytea) AND (role = 'read'::permission_role) AND (user_id = (current_setting('nimble.user_id'::text))::bytea))
  • Heap Fetches: 200
6. 0.000 0.000 ↓ 0.0 0

Index Only Scan using ix_contacts__groups_rls_associations on contacts__groups_rls_associations (cost=0.28..7.21 rows=1 width=0) (never executed)

  • Index Cond: ((company_id = (current_setting('nimble.company_id'::text))::bytea) AND (role = 'read'::permission_role) AND (contact_id = contacts.id))
  • Filter: (group_id = ANY ((string_to_array(current_setting('nimble.group_ids'::text), ','::text))::bytea[]))
  • Heap Fetches: 0
7. 0.396 0.396 ↑ 1.0 200 1

Index Only Scan using ix_contacts__groups_rls_associations on contacts__groups_rls_associations contacts__groups_rls_associations_1 (cost=0.28..15.19 rows=200 width=13) (actual time=0.029..0.396 rows=200 loops=1)

  • Index Cond: ((company_id = (current_setting('nimble.company_id'::text))::bytea) AND (role = 'read'::permission_role))
  • Filter: (group_id = ANY ((string_to_array(current_setting('nimble.group_ids'::text), ','::text))::bytea[]))
  • Heap Fetches: 200
8. 0.000 0.000 ↓ 0.0 0

Index Only Scan using ix_contacts__users_rls_associations on contacts__users_rls_associations contacts__users_rls_associations_2 (cost=0.29..2.51 rows=1 width=0) (never executed)

  • Index Cond: ((company_id = (current_setting('nimble.company_id'::text))::bytea) AND (role = 'read and edit'::permission_role) AND (user_id = (current_setting('nimble.user_id'::text))::bytea) AND (contact_id = contacts.id))
  • Heap Fetches: 0
9. 0.092 0.092 ↑ 1.0 200 1

Index Only Scan using ix_contacts__users_rls_associations on contacts__users_rls_associations contacts__users_rls_associations_3 (cost=0.29..11.19 rows=200 width=13) (actual time=0.028..0.092 rows=200 loops=1)

  • Index Cond: ((company_id = (current_setting('nimble.company_id'::text))::bytea) AND (role = 'read and edit'::permission_role) AND (user_id = (current_setting('nimble.user_id'::text))::bytea))
  • Heap Fetches: 200
10. 0.000 0.000 ↓ 0.0 0

Index Only Scan using ix_contacts__groups_rls_associations on contacts__groups_rls_associations contacts__groups_rls_associations_2 (cost=0.28..7.21 rows=1 width=0) (never executed)

  • Index Cond: ((company_id = (current_setting('nimble.company_id'::text))::bytea) AND (role = 'read and edit'::permission_role) AND (contact_id = contacts.id))
  • Filter: (group_id = ANY ((string_to_array(current_setting('nimble.group_ids'::text), ','::text))::bytea[]))
  • Heap Fetches: 0
11. 0.411 0.411 ↑ 1.0 200 1

Index Only Scan using ix_contacts__groups_rls_associations on contacts__groups_rls_associations contacts__groups_rls_associations_3 (cost=0.28..15.19 rows=200 width=13) (actual time=0.018..0.411 rows=200 loops=1)

  • Index Cond: ((company_id = (current_setting('nimble.company_id'::text))::bytea) AND (role = 'read and edit'::permission_role))
  • Filter: (group_id = ANY ((string_to_array(current_setting('nimble.group_ids'::text), ','::text))::bytea[]))
  • Heap Fetches: 200
Planning time : 0.861 ms
Execution time : 1,140.426 ms