explain.depesz.com

PostgreSQL's explain analyze made readable

Result: tUzU

Settings
# exclusive inclusive rows x rows loops node
1. 0.002 0.707 ↑ 2.0 1 1

Result (cost=1.96..29.55 rows=2 width=515) (actual time=0.706..0.707 rows=1 loops=1)

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

Nested Loop Left Join (cost=1.96..29.55 rows=2 width=515) (actual time=0.704..0.705 rows=1 loops=1)

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

Nested Loop Left Join (cost=1.39..13.79 rows=1 width=374) (actual time=0.145..0.145 rows=1 loops=1)

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

Nested Loop Left Join (cost=0.98..8.32 rows=1 width=233) (actual time=0.129..0.129 rows=1 loops=1)

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

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

  • Index Cond: ((company_id = '\x4d670aba143e3287b9d4427a'::bytea) AND (id = '\x55faf8831d4d27483aa20028'::bytea))
  • Filter: (((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.014 0.106 ↑ 1.0 1 1

GroupAggregate (cost=0.55..5.59 rows=1 width=141) (actual time=0.106..0.106 rows=1 loops=1)

  • Group Key: contacts__addresses.contact_id
7. 0.029 0.092 ↓ 7.0 7 1

Index Scan using contacts__addresses_pkey on contacts__addresses (cost=0.55..5.56 rows=1 width=90) (actual time=0.052..0.092 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.063 0.063 ↑ 1.0 1 7

Index Scan using contacts_pkey on contacts contacts_1 (cost=0.44..2.79 rows=1 width=1) (actual time=0.009..0.009 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 (((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.014 ↓ 0.0 0 1

GroupAggregate (cost=0.41..5.45 rows=1 width=141) (actual time=0.014..0.014 rows=0 loops=1)

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

Index Scan using contacts__timestamps_pkey on contacts__timestamps (cost=0.41..5.42 rows=1 width=45) (actual time=0.014..0.014 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.79 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 (((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.117 0.558 ↑ 2.0 1 1

GroupAggregate (cost=0.56..15.71 rows=2 width=141) (actual time=0.558..0.558 rows=1 loops=1)

  • Group Key: contacts_values.contact_id
15. 0.069 0.441 ↓ 31.0 62 1

Index Scan using contacts_values_pkey on contacts_values (cost=0.56..15.64 rows=2 width=60) (actual time=0.036..0.441 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.372 0.372 ↑ 1.0 1 62

Index Scan using contacts_pkey on contacts contacts_2 (cost=0.44..2.79 rows=1 width=1) (actual time=0.006..0.006 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 (((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.257 ms
Execution time : 1.248 ms