explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 2O0D

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 0.558 ↓ 3.0 3 1

Result (cost=67.34..73.22 rows=1 width=515) (actual time=0.506..0.558 rows=3 loops=1)

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

Initplan (for Result)

3. 0.009 0.009 ↑ 1.0 1 1

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

4. 0.000 0.555 ↓ 3.0 3 1

Nested Loop Left Join (cost=67.34..73.22 rows=1 width=515) (actual time=0.503..0.555 rows=3 loops=1)

  • Join Filter: (contacts.id = contacts__timestamps.contact_id)
5. 0.001 0.531 ↓ 3.0 3 1

Nested Loop Left Join (cost=58.83..64.64 rows=1 width=374) (actual time=0.479..0.531 rows=3 loops=1)

  • Join Filter: (contacts.id = contacts_values.contact_id)
  • Rows Removed by Join Filter: 3
6. 0.004 0.140 ↓ 3.0 3 1

Nested Loop Left Join (cost=9.34..14.75 rows=1 width=233) (actual time=0.125..0.140 rows=3 loops=1)

  • Join Filter: (contacts.id = contacts__addresses.contact_id)
  • Rows Removed by Join Filter: 3
7. 0.040 0.040 ↓ 3.0 3 1

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

  • Index Cond: ((company_id = '\x4d670aba143e3287b9d4427a'::bytea) AND (id = ANY ('{""\\x56b1303eb2a6bd497256f7f2"",""\\x56b1303fb2a6bd497256f7ff"",""\\x56b1303fb2a6bd497256f808""}'::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[]))
8. 0.015 0.096 ↓ 2.0 2 3

GroupAggregate (cost=8.91..8.95 rows=1 width=141) (actual time=0.031..0.032 rows=2 loops=3)

  • Group Key: contacts__addresses.contact_id
9. 0.014 0.081 ↓ 2.0 2 3

Sort (cost=8.91..8.91 rows=1 width=90) (actual time=0.027..0.027 rows=2 loops=3)

  • Sort Key: contacts__addresses.contact_id
  • Sort Method: quicksort Memory: 25kB
10. 0.045 0.067 ↓ 2.0 2 1

Index Scan using contacts__addresses_pkey on contacts__addresses (cost=0.55..8.90 rows=1 width=90) (actual time=0.058..0.067 rows=2 loops=1)

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

SubPlan (for Index Scan)

12. 0.018 0.022 ↑ 1.0 1 2

Index Scan using contacts_pkey on contacts contacts_1 (cost=0.45..2.81 rows=1 width=1) (actual time=0.011..0.011 rows=1 loops=2)

  • 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.004 0.004 ↑ 1.0 1 1

Function Scan on can_view_all_contacts_1 (cost=0.01..0.02 rows=1 width=1) (actual time=0.004..0.004 rows=1 loops=1)

15. 0.042 0.390 ↑ 3.5 2 3

GroupAggregate (cost=49.49..49.74 rows=7 width=141) (actual time=0.121..0.130 rows=2 loops=3)

  • Group Key: contacts_values.contact_id
16. 0.043 0.348 ↓ 3.4 24 3

Sort (cost=49.49..49.51 rows=7 width=60) (actual time=0.110..0.116 rows=24 loops=3)

  • Sort Key: contacts_values.contact_id
  • Sort Method: quicksort Memory: 30kB
17. 0.109 0.305 ↓ 7.0 49 1

Index Scan using contacts_values_pkey on contacts_values (cost=0.56..49.39 rows=7 width=60) (actual time=0.055..0.305 rows=49 loops=1)

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

SubPlan (for Index Scan)

19. 0.192 0.196 ↑ 1.0 1 49

Index Scan using contacts_pkey on contacts contacts_2 (cost=0.45..2.81 rows=1 width=1) (actual time=0.004..0.004 rows=1 loops=49)

  • 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.004 0.004 ↑ 1.0 1 1

Function Scan on can_view_all_contacts_2 (cost=0.01..0.02 rows=1 width=1) (actual time=0.004..0.004 rows=1 loops=1)

22. 0.000 0.024 ↓ 0.0 0 3

GroupAggregate (cost=8.49..8.52 rows=1 width=141) (actual time=0.008..0.008 rows=0 loops=3)

  • Group Key: contacts__timestamps.contact_id
23. 0.008 0.024 ↓ 0.0 0 3

Sort (cost=8.49..8.49 rows=1 width=45) (actual time=0.008..0.008 rows=0 loops=3)

  • Sort Key: contacts__timestamps.contact_id
  • Sort Method: quicksort Memory: 25kB
24. 0.016 0.016 ↓ 0.0 0 1

Index Scan using contacts__timestamps_pkey on contacts__timestamps (cost=0.41..8.48 rows=1 width=45) (actual time=0.016..0.016 rows=0 loops=1)

  • Index Cond: ((company_id = '\x4d670aba143e3287b9d4427a'::bytea) AND (contact_id = ANY ('{""\\x56b1303eb2a6bd497256f7f2"",""\\x56b1303fb2a6bd497256f7ff"",""\\x56b1303fb2a6bd497256f808""}'::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.495 ms
Execution time : 1.091 ms