explain.depesz.com

PostgreSQL's explain analyze made readable

Result: uEnY

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

Result (cost=1.96..32.90 rows=2 width=515) (actual time=0.327..0.328 rows=1 loops=1)

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

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

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

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

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

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

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

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

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

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

  • Group Key: contacts__addresses.contact_id
7. 0.030 0.084 ↓ 9.0 9 1

Index Scan using contacts__addresses_pkey on contacts__addresses (cost=0.55..5.56 rows=1 width=90) (actual time=0.035..0.084 rows=9 loops=1)

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

SubPlan (for Index Scan)

9. 0.054 0.054 ↑ 1.0 1 9

Index Scan using contacts_pkey on contacts contacts_1 (cost=0.44..2.79 rows=1 width=1) (actual time=0.006..0.006 rows=1 loops=9)

  • 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 = (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.001 0.020 ↓ 0.0 0 1

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

  • Group Key: contacts__timestamps.contact_id
11. 0.019 0.019 ↓ 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.019..0.019 rows=0 loops=1)

  • Index Cond: ((company_id = '\x4d670aba143e3287b9d4427a'::bytea) AND (contact_id = '\x55faf7711d4d27483aa17ce7'::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 = (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.020 0.179 ↑ 2.0 1 1

GroupAggregate (cost=0.56..19.06 rows=2 width=141) (actual time=0.179..0.179 rows=1 loops=1)

  • Group Key: contacts_values.contact_id
15. 0.049 0.159 ↓ 11.0 22 1

Index Scan using contacts_values_pkey on contacts_values (cost=0.56..19.00 rows=2 width=59) (actual time=0.035..0.159 rows=22 loops=1)

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

SubPlan (for Index Scan)

17. 0.110 0.110 ↑ 1.0 1 22

Index Scan using contacts_pkey on contacts contacts_2 (cost=0.44..2.79 rows=1 width=1) (actual time=0.005..0.005 rows=1 loops=22)

  • 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 = (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.818 ms
Execution time : 0.780 ms