explain.depesz.com

PostgreSQL's explain analyze made readable

Result: WrGh

Settings
# exclusive inclusive rows x rows loops node
1. 0.004 0.876 ↑ 2.0 1 1

Result (cost=1.96..29.60 rows=2 width=515) (actual time=0.875..0.876 rows=1 loops=1)

  • One-Time Filter: ((current_setting('nimble.company_id'::text))::bytea = '\x4d670aba143e3287b9d4427a'::bytea)
2. 0.001 0.872 ↑ 2.0 1 1

Nested Loop Left Join (cost=1.96..29.60 rows=2 width=515) (actual time=0.872..0.872 rows=1 loops=1)

  • Join Filter: (contacts.id = contacts_values.contact_id)
3. 0.001 0.232 ↑ 1.0 1 1

Nested Loop Left Join (cost=1.39..13.82 rows=1 width=374) (actual time=0.231..0.232 rows=1 loops=1)

  • Join Filter: (contacts.id = contacts__timestamps.contact_id)
4. 0.003 0.219 ↑ 1.0 1 1

Nested Loop Left Join (cost=0.98..8.34 rows=1 width=233) (actual time=0.218..0.219 rows=1 loops=1)

  • Join Filter: (contacts.id = contacts__addresses.contact_id)
5. 0.029 0.029 ↑ 1.0 1 1

Index Scan using contacts_pkey on contacts (cost=0.43..2.71 rows=1 width=92) (actual time=0.029..0.029 rows=1 loops=1)

  • Index Cond: ((company_id = '\x4d670aba143e3287b9d4427a'::bytea) AND (id = '\x55faf8831d4d27483aa20028'::bytea))
  • Filter: ((current_setting('nimble.view_all_contacts'::text))::boolean OR ((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[]))
6. 0.012 0.187 ↑ 1.0 1 1

GroupAggregate (cost=0.55..5.60 rows=1 width=141) (actual time=0.187..0.187 rows=1 loops=1)

  • Group Key: contacts__addresses.contact_id
7. 0.035 0.175 ↓ 7.0 7 1

Index Scan using contacts__addresses_pkey on contacts__addresses (cost=0.55..5.57 rows=1 width=90) (actual time=0.131..0.175 rows=7 loops=1)

  • Index Cond: ((company_id = '\x4d670aba143e3287b9d4427a'::bytea) AND (contact_id = '\x55faf8831d4d27483aa20028'::bytea))
  • Filter: ((SubPlan 1) IS TRUE)
8.          

SubPlan (for Index Scan)

9. 0.140 0.140 ↑ 1.0 1 7

Index Scan using contacts_pkey on contacts contacts_1 (cost=0.44..2.80 rows=1 width=1) (actual time=0.020..0.020 rows=1 loops=7)

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

GroupAggregate (cost=0.41..5.46 rows=1 width=141) (actual time=0.012..0.012 rows=0 loops=1)

  • Group Key: contacts__timestamps.contact_id
11. 0.012 0.012 ↓ 0.0 0 1

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

  • Index Cond: ((company_id = '\x4d670aba143e3287b9d4427a'::bytea) AND (contact_id = '\x55faf8831d4d27483aa20028'::bytea))
  • Filter: ((SubPlan 3) IS TRUE)
12.          

SubPlan (for Index Scan)

13. 0.000 0.000 ↓ 0.0 0

Index Scan using contacts_pkey on contacts contacts_3 (cost=0.44..2.80 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 ((current_setting('nimble.view_all_contacts'::text))::boolean OR ((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[])))
14. 0.057 0.639 ↑ 2.0 1 1

GroupAggregate (cost=0.56..15.74 rows=2 width=141) (actual time=0.639..0.639 rows=1 loops=1)

  • Group Key: contacts_values.contact_id
15. 0.148 0.582 ↓ 31.0 62 1

Index Scan using contacts_values_pkey on contacts_values (cost=0.56..15.67 rows=2 width=60) (actual time=0.049..0.582 rows=62 loops=1)

  • Index Cond: ((company_id = '\x4d670aba143e3287b9d4427a'::bytea) AND (contact_id = '\x55faf8831d4d27483aa20028'::bytea))
  • Filter: ((SubPlan 2) IS TRUE)
16.          

SubPlan (for Index Scan)

17. 0.434 0.434 ↑ 1.0 1 62

Index Scan using contacts_pkey on contacts contacts_2 (cost=0.44..2.80 rows=1 width=1) (actual time=0.007..0.007 rows=1 loops=62)

  • Index Cond: ((company_id = (current_setting('nimble.company_id'::text))::bytea) AND (id = contacts_values.contact_id))
  • Filter: ((company_id = company_id) AND ((current_setting('nimble.view_all_contacts'::text))::boolean OR ((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[])))
Planning time : 4.139 ms
Execution time : 1.615 ms