explain.depesz.com

PostgreSQL's explain analyze made readable

Result: WEqg

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 0.105 ↓ 0.0 0 1

Result (cost=87.19..93.24 rows=1 width=515) (actual time=0.105..0.105 rows=0 loops=1)

  • One-Time Filter: ((current_setting('nimble.company_id'::text))::bytea = '\x4d670aba143e3287b9d4427a'::bytea)
2.          

Initplan (for Result)

3. 0.013 0.013 ↑ 1.0 1 1

Function Scan on can_view_all_contacts (cost=0.01..0.02 rows=1 width=1) (actual time=0.012..0.013 rows=1 loops=1)

4. 0.000 0.100 ↓ 0.0 0 1

Nested Loop Left Join (cost=87.19..93.24 rows=1 width=515) (actual time=0.100..0.100 rows=0 loops=1)

  • Join Filter: (contacts.id = contacts__timestamps.contact_id)
5. 0.000 0.100 ↓ 0.0 0 1

Nested Loop Left Join (cost=78.68..84.66 rows=1 width=374) (actual time=0.100..0.100 rows=0 loops=1)

  • Join Filter: (contacts.id = contacts_values.contact_id)
6. 0.001 0.100 ↓ 0.0 0 1

Nested Loop Left Join (cost=29.19..34.77 rows=1 width=233) (actual time=0.100..0.100 rows=0 loops=1)

  • Join Filter: (contacts.id = contacts__addresses.contact_id)
7. 0.099 0.099 ↓ 0.0 0 1

Index Scan using contacts_pkey on contacts (cost=0.43..5.78 rows=1 width=92) (actual time=0.099..0.099 rows=0 loops=1)

  • Index Cond: ((company_id = '\x4d670aba143e3287b9d4427a'::bytea) AND (id = ANY ('{""\\x55faf7711d4d27483aa17ce7"",""\\x55faf7731d4d27483aa17e6f"",""\\x55faf77d1d4d27483aa1832a""}'::bytea[])))
  • Filter: ($0 OR (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: 3
8. 0.000 0.000 ↓ 0.0 0

GroupAggregate (cost=28.76..28.90 rows=4 width=141) (never executed)

  • Group Key: contacts__addresses.contact_id
9. 0.000 0.000 ↓ 0.0 0

Sort (cost=28.76..28.77 rows=4 width=90) (never executed)

  • Sort Key: contacts__addresses.contact_id
10. 0.000 0.000 ↓ 0.0 0

Index Scan using contacts__addresses_pkey on contacts__addresses (cost=0.55..28.72 rows=4 width=90) (never executed)

  • Index Cond: ((company_id = '\x4d670aba143e3287b9d4427a'::bytea) AND (contact_id = ANY ('{""\\x55faf7711d4d27483aa17ce7"",""\\x55faf7731d4d27483aa17e6f"",""\\x55faf77d1d4d27483aa1832a""}'::bytea[])))
  • Filter: ((SubPlan 3) IS TRUE)
11.          

SubPlan (for Index Scan)

12. 0.000 0.000 ↓ 0.0 0

Index Scan using contacts_pkey on contacts contacts_1 (cost=0.45..2.81 rows=1 width=1) (never executed)

  • Index Cond: ((company_id = (current_setting('nimble.company_id'::text))::bytea) AND (id = contacts__addresses.contact_id))
  • Filter: ((company_id = company_id) AND ($2 OR (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[])))
13.          

Initplan (for Index Scan)

14. 0.000 0.000 ↓ 0.0 0

Function Scan on can_view_all_contacts_1 (cost=0.01..0.02 rows=1 width=1) (never executed)

15. 0.000 0.000 ↓ 0.0 0

GroupAggregate (cost=49.49..49.74 rows=7 width=141) (never executed)

  • Group Key: contacts_values.contact_id
16. 0.000 0.000 ↓ 0.0 0

Sort (cost=49.49..49.51 rows=7 width=60) (never executed)

  • Sort Key: contacts_values.contact_id
17. 0.000 0.000 ↓ 0.0 0

Index Scan using contacts_values_pkey on contacts_values (cost=0.56..49.39 rows=7 width=60) (never executed)

  • Index Cond: ((company_id = '\x4d670aba143e3287b9d4427a'::bytea) AND (contact_id = ANY ('{""\\x55faf7711d4d27483aa17ce7"",""\\x55faf7731d4d27483aa17e6f"",""\\x55faf77d1d4d27483aa1832a""}'::bytea[])))
  • Filter: ((SubPlan 5) IS TRUE)
18.          

SubPlan (for Index Scan)

19. 0.000 0.000 ↓ 0.0 0

Index Scan using contacts_pkey on contacts contacts_2 (cost=0.45..2.81 rows=1 width=1) (never executed)

  • Index Cond: ((company_id = (current_setting('nimble.company_id'::text))::bytea) AND (id = contacts_values.contact_id))
  • Filter: ((company_id = company_id) AND ($4 OR (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[])))
20.          

Initplan (for Index Scan)

21. 0.000 0.000 ↓ 0.0 0

Function Scan on can_view_all_contacts_2 (cost=0.01..0.02 rows=1 width=1) (never executed)

22. 0.000 0.000 ↓ 0.0 0

GroupAggregate (cost=8.49..8.52 rows=1 width=141) (never executed)

  • Group Key: contacts__timestamps.contact_id
23. 0.000 0.000 ↓ 0.0 0

Sort (cost=8.49..8.49 rows=1 width=45) (never executed)

  • Sort Key: contacts__timestamps.contact_id
24. 0.000 0.000 ↓ 0.0 0

Index Scan using contacts__timestamps_pkey on contacts__timestamps (cost=0.41..8.48 rows=1 width=45) (never executed)

  • Index Cond: ((company_id = '\x4d670aba143e3287b9d4427a'::bytea) AND (contact_id = ANY ('{""\\x55faf7711d4d27483aa17ce7"",""\\x55faf7731d4d27483aa17e6f"",""\\x55faf77d1d4d27483aa1832a""}'::bytea[])))
  • Filter: ((SubPlan 7) IS TRUE)
25.          

SubPlan (for Index Scan)

26. 0.000 0.000 ↓ 0.0 0

Index Scan using contacts_pkey on contacts contacts_3 (cost=0.45..2.81 rows=1 width=1) (never executed)

  • Index Cond: ((company_id = (current_setting('nimble.company_id'::text))::bytea) AND (id = contacts__timestamps.contact_id))
  • Filter: ((company_id = company_id) AND ($6 OR (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[])))
27.          

Initplan (for Index Scan)

28. 0.000 0.000 ↓ 0.0 0

Function Scan on can_view_all_contacts_3 (cost=0.01..0.02 rows=1 width=1) (never executed)

Planning time : 3.038 ms
Execution time : 1.022 ms