explain.depesz.com

PostgreSQL's explain analyze made readable

Result: E4s6

Settings
# exclusive inclusive rows x rows loops node
1. 0.046 795.724 ↑ 1.0 1 1

Aggregate (cost=31,795.90..31,795.91 rows=1 width=8) (actual time=795.723..795.724 rows=1 loops=1)

2. 0.178 795.678 ↓ 578.0 578 1

Unique (cost=31,795.88..31,795.89 rows=1 width=4) (actual time=795.370..795.678 rows=578 loops=1)

3. 0.685 795.500 ↓ 1,638.0 1,638 1

Sort (cost=31,795.88..31,795.89 rows=1 width=4) (actual time=795.370..795.500 rows=1,638 loops=1)

  • Sort Key: clients_client.id
  • Sort Method: quicksort Memory: 125kB
4. 0.193 794.815 ↓ 1,638.0 1,638 1

Nested Loop Semi Join (cost=26,073.59..31,795.87 rows=1 width=4) (actual time=197.887..794.815 rows=1,638 loops=1)

5. 0.673 783.156 ↓ 1,638.0 1,638 1

Nested Loop (cost=26,072.60..31,794.53 rows=1 width=8) (actual time=197.859..783.156 rows=1,638 loops=1)

  • Join Filter: (clients_client.id = t7.client_id)
6. 3.569 779.207 ↓ 1,638.0 1,638 1

Nested Loop (cost=26,072.18..31,794.01 rows=1 width=8) (actual time=197.854..779.207 rows=1,638 loops=1)

7. 56.069 764.996 ↓ 5,321.0 5,321 1

Nested Loop Left Join (cost=26,071.76..31,793.44 rows=1 width=4) (actual time=197.101..764.996 rows=5,321 loops=1)

  • Filter: ((clients_client_agents.user_id = 30738) OR (hashed SubPlan 1))
  • Rows Removed by Filter: 110724
8. 0.000 476.820 ↓ 116,039.0 116,039 1

Nested Loop Left Join (cost=26,065.53..31,787.11 rows=1 width=8) (actual time=197.029..476.820 rows=116,039 loops=1)

9. 56.640 219.396 ↓ 88,796.0 88,796 1

Hash Right Join (cost=26,065.10..31,786.58 rows=1 width=4) (actual time=197.002..219.396 rows=88,796 loops=1)

  • Hash Cond: (units_tenant.client_id = clients_client.id)
  • Filter: (units_tenant.id IS NULL)
  • Rows Removed by Filter: 431
10. 38.710 38.710 ↑ 1.0 213,906 1

Seq Scan on units_tenant (cost=0.00..5,159.16 rows=214,216 width=8) (actual time=0.009..38.710 rows=213,906 loops=1)

11. 16.527 124.046 ↓ 2.0 89,190 1

Hash (cost=25,496.68..25,496.68 rows=45,474 width=4) (actual time=124.046..124.046 rows=89,190 loops=1)

  • Buckets: 131072 (originally 65536) Batches: 1 (originally 1) Memory Usage: 4160kB
12. 78.721 107.519 ↓ 2.0 89,190 1

Index Scan using clients_client_brokerage_id on clients_client (cost=6,502.38..25,496.68 rows=45,474 width=4) (actual time=30.415..107.519 rows=89,190 loops=1)

  • Index Cond: (brokerage_id = 18855)
  • Filter: ((status <> ALL ('{50,70}'::integer[])) AND (NOT (hashed SubPlan 2)))
  • Rows Removed by Filter: 10828
13.          

SubPlan (for Index Scan)

14. 28.798 28.798 ↓ 1.1 7,851 1

Seq Scan on appointments_appointment u1_2 (cost=0.00..6,483.74 rows=7,287 width=4) (actual time=0.058..28.798 rows=7,851 loops=1)

  • Filter: (start > '2020-05-14 15:06:14.467669'::timestamp without time zone)
  • Rows Removed by Filter: 168223
15. 266.388 266.388 ↑ 1.0 1 88,796

Index Only Scan using clients_client_agents_client_id_37afacd828f1e2f6_uniq on clients_client_agents (cost=0.42..0.52 rows=1 width=8) (actual time=0.002..0.003 rows=1 loops=88,796)

  • Index Cond: (client_id = clients_client.id)
  • Heap Fetches: 59948
16. 232.078 232.078 ↑ 1.0 1 116,039

Index Only Scan using clients_groupassignment_client_id_group_id_55417b62_uniq on clients_groupassignment (cost=0.42..0.51 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=116,039)

  • Index Cond: (client_id = clients_client.id)
  • Heap Fetches: 8542
17.          

SubPlan (for Nested Loop Left Join)

18. 0.003 0.029 ↓ 4.0 8 1

Nested Loop (cost=0.56..5.80 rows=2 width=4) (actual time=0.014..0.029 rows=8 loops=1)

19. 0.010 0.010 ↓ 4.0 8 1

Index Scan using accounts_employeegroup_employees_e8701ad4 on accounts_employeegroup_employees u1_1 (cost=0.29..3.01 rows=2 width=4) (actual time=0.005..0.010 rows=8 loops=1)

  • Index Cond: (user_id = 30738)
20. 0.016 0.016 ↑ 1.0 1 8

Index Only Scan using accounts_employeegroup_pkey on accounts_employeegroup u0_1 (cost=0.28..1.40 rows=1 width=4) (actual time=0.002..0.002 rows=1 loops=8)

  • Index Cond: (id = u1_1.employeegroup_id)
  • Heap Fetches: 1
21. 10.642 10.642 ↓ 0.0 0 5,321

Index Scan using appointments_appointment_client_id_70ec2332b48b8895_uniq on appointments_appointment (cost=0.42..0.56 rows=1 width=4) (actual time=0.002..0.002 rows=0 loops=5,321)

  • Index Cond: (client_id = clients_client.id)
  • Filter: (start < '2020-05-14 15:06:14.467669'::timestamp without time zone)
22. 3.276 3.276 ↑ 1.0 1 1,638

Index Scan using clients_groupassignment_client_id_group_id_55417b62_uniq on clients_groupassignment t7 (cost=0.42..0.51 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=1,638)

  • Index Cond: (client_id = appointments_appointment.client_id)
23. 0.000 11.466 ↑ 1.0 1 1,638

Nested Loop (cost=0.99..1.33 rows=1 width=4) (actual time=0.007..0.007 rows=1 loops=1,638)

24. 1.638 8.190 ↑ 1.0 1 1,638

Nested Loop (cost=0.70..0.88 rows=1 width=12) (actual time=0.005..0.005 rows=1 loops=1,638)

25. 3.276 3.276 ↑ 1.0 1 1,638

Index Scan using clients_groupassignment_pkey on clients_groupassignment u0 (cost=0.42..0.48 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=1,638)

  • Index Cond: (id = t7.id)
  • Filter: ((status = ANY ('{40,10,15,80,20,30}'::integer[])) AND (group_id = ANY ('{1281,1191,1293,1102,1296,1204,1113,1246}'::integer[])))
26. 3.276 3.276 ↑ 1.0 1 1,638

Index Scan using accounts_employeegroup_pkey on accounts_employeegroup u1 (cost=0.28..0.39 rows=1 width=4) (actual time=0.002..0.002 rows=1 loops=1,638)

  • Index Cond: (id = u0.group_id)
  • Filter: (company_id = 18855)
27. 3.276 3.276 ↑ 1.0 1 1,638

Index Only Scan using accounts_employeegroup_employees_employeegroup_id_user_id_key on accounts_employeegroup_employees u3 (cost=0.29..0.39 rows=1 width=4) (actual time=0.002..0.002 rows=1 loops=1,638)

  • Index Cond: ((employeegroup_id = u0.group_id) AND (user_id = 30738))
  • Heap Fetches: 216
Planning time : 3.181 ms
Execution time : 796.084 ms