explain.depesz.com

PostgreSQL's explain analyze made readable

Result: kzWX

Settings
# exclusive inclusive rows x rows loops node
1. 0.028 148.346 ↑ 1.0 1 1

Aggregate (cost=37,165.32..37,165.33 rows=1 width=8) (actual time=148.346..148.346 rows=1 loops=1)

2. 0.058 148.318 ↓ 458.0 458 1

Unique (cost=37,165.30..37,165.31 rows=1 width=4) (actual time=148.237..148.318 rows=458 loops=1)

3. 0.129 148.260 ↓ 458.0 458 1

Sort (cost=37,165.30..37,165.31 rows=1 width=4) (actual time=148.236..148.260 rows=458 loops=1)

  • Sort Key: clients_client.id
  • Sort Method: quicksort Memory: 46kB
4. 0.000 148.131 ↓ 458.0 458 1

Nested Loop (cost=33,610.52..37,165.29 rows=1 width=4) (actual time=141.920..148.131 rows=458 loops=1)

  • Join Filter: (clients_client_agents.client_id = clients_client.id)
5. 0.321 146.680 ↓ 11.9 498 1

Hash Semi Join (cost=33,610.09..37,143.50 rows=42 width=8) (actual time=141.905..146.680 rows=498 loops=1)

  • Hash Cond: (clients_groupassignment.id = v0.id)
6. 0.984 4.540 ↓ 1.1 1,410 1

Nested Loop (cost=0.85..3,530.54 rows=1,237 width=12) (actual time=0.023..4.540 rows=1,410 loops=1)

7. 0.736 0.736 ↓ 1.1 1,410 1

Index Scan using clients_client_agents_user_id on clients_client_agents (cost=0.42..428.44 rows=1,330 width=4) (actual time=0.014..0.736 rows=1,410 loops=1)

  • Index Cond: (user_id = 31484)
8. 2.820 2.820 ↑ 1.0 1 1,410

Index Scan using clients_groupassignment_client_id_4c897251 on clients_groupassignment (cost=0.42..2.32 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=1,410)

  • Index Cond: (client_id = clients_client_agents.client_id)
9. 3.368 141.819 ↓ 1.4 23,358 1

Hash (cost=33,407.86..33,407.86 rows=16,111 width=4) (actual time=141.819..141.819 rows=23,358 loops=1)

  • Buckets: 32768 (originally 16384) Batches: 1 (originally 1) Memory Usage: 1078kB
10. 16.895 138.451 ↓ 1.4 23,358 1

Merge Right Join (cost=30,708.87..33,407.86 rows=16,111 width=4) (actual time=124.253..138.451 rows=23,358 loops=1)

  • Merge Cond: (v4.client_id = v3.id)
  • Filter: ((v0.status = ANY ('{10,20,15}'::integer[])) OR ((v0.status = 30) AND (hashed SubPlan 1)))
  • Rows Removed by Filter: 3686
11. 28.413 28.413 ↑ 3.1 68,434 1

Index Scan using units_tenant_client_id on units_tenant v4 (cost=0.42..7,210.78 rows=214,145 width=8) (actual time=0.008..28.413 rows=68,434 loops=1)

12. 9.535 64.444 ↑ 1.3 27,044 1

Sort (cost=24,705.65..24,796.79 rows=36,458 width=12) (actual time=62.008..64.444 rows=27,044 loops=1)

  • Sort Key: v3.id
  • Sort Method: quicksort Memory: 2035kB
13. 4.917 54.909 ↑ 1.3 27,011 1

Gather (cost=1,143.92..21,943.24 rows=36,458 width=12) (actual time=1.339..54.909 rows=27,011 loops=1)

  • Workers Planned: 2
  • Workers Launched: 2
14. 1.500 49.992 ↑ 1.7 9,004 3 / 3

Nested Loop (cost=143.92..17,297.44 rows=15,191 width=12) (actual time=0.232..49.992 rows=9,004 loops=3)

15. 6.890 30.485 ↑ 1.7 9,004 3 / 3

Hash Join (cost=143.50..10,292.36 rows=15,191 width=12) (actual time=0.213..30.485 rows=9,004 loops=3)

  • Hash Cond: (v0.group_id = v1.id)
16. 23.418 23.418 ↑ 1.2 74,218 3 / 3

Parallel Seq Scan on clients_groupassignment v0 (cost=0.00..9,909.73 rows=90,840 width=16) (actual time=0.008..23.418 rows=74,218 loops=3)

  • Filter: ((status = ANY ('{10,20,15}'::integer[])) OR (status = 30))
  • Rows Removed by Filter: 82043
17. 0.033 0.177 ↑ 1.0 249 3 / 3

Hash (cost=140.39..140.39 rows=249 width=4) (actual time=0.177..0.177 rows=249 loops=3)

  • Buckets: 1024 Batches: 1 Memory Usage: 17kB
18. 0.144 0.144 ↑ 1.0 249 3 / 3

Index Scan using accounts_employeegroup_447d3092 on accounts_employeegroup v1 (cost=0.28..140.39 rows=249 width=4) (actual time=0.015..0.144 rows=249 loops=3)

  • Index Cond: (company_id = 18855)
19. 18.007 18.007 ↑ 1.0 1 27,011 / 3

Index Only Scan using clients_client_pkey on clients_client v3 (cost=0.42..0.46 rows=1 width=4) (actual time=0.002..0.002 rows=1 loops=27,011)

  • Index Cond: (id = v0.client_id)
  • Heap Fetches: 3797
20. 0.203 28.699 ↓ 11.9 155 1

SubPlan 1-> Nested Loop (cost=1.71..6,002.77 rows=13 width=4) (actual time=0.199..28.699 rows=155 loops=1)

21. 0.773 28.104 ↓ 392.0 392 1

Nested Loop (cost=1.28..6,000.17 rows=1 width=4) (actual time=0.190..28.104 rows=392 loops=1)

22. 1.760 12.773 ↓ 40.1 14,558 1

Nested Loop (cost=0.86..5,821.77 rows=363 width=4) (actual time=0.026..12.773 rows=14,558 loops=1)

23. 0.101 0.101 ↓ 1.8 248 1

Index Scan using units_building_management_company_id on units_building u2 (cost=0.43..157.02 rows=140 width=4) (actual time=0.013..0.101 rows=248 loops=1)

  • Index Cond: (management_company_id = 18855)
24. 10.912 10.912 ↓ 1.7 59 248

Index Scan using units_unit_4c63c6ae on units_unit u1 (cost=0.43..40.11 rows=35 width=8) (actual time=0.004..0.044 rows=59 loops=248)

  • Index Cond: (building_id = u2.id)
25. 14.558 14.558 ↓ 0.0 0 14,558

Index Scan using units_tenant_e8175980 on units_tenant u0 (cost=0.42..0.48 rows=1 width=8) (actual time=0.001..0.001 rows=0 loops=14,558)

  • Index Cond: (unit_id = u1.id)
  • Filter: (lease_start_date >= '2020-04-20'::date)
  • Rows Removed by Filter: 0
26. 0.392 0.392 ↓ 0.0 0 392

Index Scan using units_unit_current_tenant_id_key on units_unit u4 (cost=0.43..2.59 rows=1 width=4) (actual time=0.001..0.001 rows=0 loops=392)

  • Index Cond: (current_tenant_id = u0.id)
  • Filter: (id IS NOT NULL)
27. 1.494 1.494 ↑ 1.0 1 498

Index Scan using clients_client_pkey on clients_client (cost=0.42..0.51 rows=1 width=4) (actual time=0.003..0.003 rows=1 loops=498)

  • Index Cond: (id = clients_groupassignment.client_id)
  • Filter: ((status <> ALL ('{50,70}'::integer[])) AND (brokerage_id = 18855))
  • Rows Removed by Filter: 0
Planning time : 4.540 ms
Execution time : 148.863 ms