explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 5q6G

Settings
# exclusive inclusive rows x rows loops node
1. 0.008 571.974 ↓ 50.0 50 1

Limit (cost=409,914.60..409,914.61 rows=1 width=12) (actual time=571.954..571.974 rows=50 loops=1)

2. 0.008 571.966 ↓ 50.0 50 1

Unique (cost=409,914.60..409,914.61 rows=1 width=12) (actual time=571.953..571.966 rows=50 loops=1)

3. 1.016 571.958 ↓ 50.0 50 1

Sort (cost=409,914.60..409,914.60 rows=1 width=12) (actual time=571.953..571.958 rows=50 loops=1)

  • Sort Key: ((SubPlan 1)) DESC NULLS LAST, clients_client.id DESC
  • Sort Method: quicksort Memory: 265kB
4. 39.347 570.942 ↓ 3,593.0 3,593 1

Nested Loop Semi Join (cost=19,749.48..409,914.59 rows=1 width=12) (actual time=76.440..570.942 rows=3,593 loops=1)

5. 130.204 240.770 ↓ 1.5 92,151 1

Hash Join (cost=19,748.78..32,524.17 rows=60,530 width=8) (actual time=76.112..240.770 rows=92,151 loops=1)

  • Hash Cond: (clients_groupassignment.client_id = clients_client.id)
6. 34.564 34.564 ↑ 1.0 469,282 1

Seq Scan on clients_groupassignment (cost=0.00..11,506.36 rows=483,436 width=8) (actual time=0.007..34.564 rows=469,282 loops=1)

7. 14.507 76.002 ↓ 1.0 92,164 1

Hash (cost=18,636.19..18,636.19 rows=89,007 width=4) (actual time=76.002..76.002 rows=92,164 loops=1)

  • Buckets: 131072 Batches: 1 Memory Usage: 4265kB
8. 61.495 61.495 ↓ 1.0 92,164 1

Index Scan using clients_client_brokerage_id on clients_client (cost=0.42..18,636.19 rows=89,007 width=4) (actual time=0.015..61.495 rows=92,164 loops=1)

  • Index Cond: (brokerage_id = 18855)
  • Filter: (status <> ALL ('{50,70}'::integer[]))
  • Rows Removed by Filter: 7226
9. 0.000 276.453 ↓ 0.0 0 92,151

Nested Loop (cost=0.70..6.22 rows=1 width=4) (actual time=0.003..0.003 rows=0 loops=92,151)

10. 171.283 276.453 ↓ 0.0 0 92,151

Index Scan using clients_groupassignment_pkey on clients_groupassignment v0 (cost=0.42..5.92 rows=1 width=8) (actual time=0.003..0.003 rows=0 loops=92,151)

  • Index Cond: (id = clients_groupassignment.id)
  • Filter: ((status = ANY ('{10,15}'::integer[])) AND (NOT (alternatives: SubPlan 2 or hashed SubPlan 3)))
  • Rows Removed by Filter: 1
  • Index Cond: (id = v0.group_id)
  • Filter: (company_id = 18855)
  • Rows Removed by Filter: 0
11.          

SubPlan (for Index Scan)

12. 2.995 105.170 ↑ 1.0 1 21,034

Nested Loop (cost=1.00..5.46 rows=1 width=0) (actual time=0.005..0.005 rows=1 loops=21,034)

13. 24.029 84.136 ↑ 1.0 1 21,034

Nested Loop (cost=0.71..5.15 rows=1 width=8) (actual time=0.004..0.004 rows=1 loops=21,034)

14. 42.068 42.068 ↑ 1.0 1 21,034

Index Only Scan using clients_client_agents_client_id_37afacd828f1e2f6_uniq on clients_client_agents u3 (cost=0.42..2.64 rows=1 width=4) (actual time=0.002..0.002 rows=1 loops=21,034)

  • Index Cond: (client_id = v0.client_id)
  • Heap Fetches: 15800
15. 18.039 18.039 ↑ 1.0 1 18,039

Index Only Scan using auth_user_pkey on auth_user u0_1 (cost=0.29..2.51 rows=1 width=4) (actual time=0.001..0.001 rows=1 loops=18,039)

  • Index Cond: (id = u3.user_id)
  • Heap Fetches: 17432
16. 18.039 18.039 ↑ 1.0 1 18,039

Index Only Scan using accounts_employeegroup_employees_employeegroup_id_user_id_key on accounts_employeegroup_employees u1 (cost=0.29..0.31 rows=1 width=4) (actual time=0.001..0.001 rows=1 loops=18,039)

  • Index Cond: ((employeegroup_id = v0.group_id) AND (user_id = u0_1.id))
  • Heap Fetches: 7426
17. 0.000 0.000 ↓ 0.0 0

Hash Join (cost=2,003.74..19,914.22 rows=571,474 width=8) (never executed)

  • Hash Cond: (u3_1.user_id = u0_2.id)
18. 0.000 0.000 ↓ 0.0 0

Seq Scan on clients_client_agents u3_1 (cost=0.00..9,820.90 rows=633,290 width=8) (never executed)

19. 0.000 0.000 ↓ 0.0 0

Hash (cost=1,684.57..1,684.57 rows=25,534 width=12) (never executed)

20. 0.000 0.000 ↓ 0.0 0

Hash Join (cost=1,209.19..1,684.57 rows=25,534 width=12) (never executed)

  • Hash Cond: (u1_1.user_id = u0_2.id)
21. 0.000 0.000 ↓ 0.0 0

Seq Scan on accounts_employeegroup_employees u1_1 (cost=0.00..408.34 rows=25,534 width=8) (never executed)

22. 0.000 0.000 ↓ 0.0 0

Hash (cost=855.49..855.49 rows=28,296 width=4) (never executed)

23. 0.000 0.000 ↓ 0.0 0

Index Only Scan using auth_user_pkey on auth_user u0_2 (cost=0.29..855.49 rows=28,296 width=4) (never executed)

24. 3.595 3.595 ↑ 1.0 1 3,595

Heap Fetches: 0-> Index Scan using accounts_employeegroup_pkey on accounts_employeegroup v1 (cost=0.28..0.30 rows=1 width=4) (actual time=0.001..0.001 rows=1 loops=3,595)

25.          

SubPlan (for Nested Loop Semi Join)

26. 3.593 14.372 ↑ 1.0 1 3,593

Limit (cost=2.65..2.65 rows=1 width=8) (actual time=0.004..0.004 rows=1 loops=3,593)

27. 3.593 10.779 ↑ 1.0 1 3,593

Sort (cost=2.65..2.65 rows=1 width=8) (actual time=0.003..0.003 rows=1 loops=3,593)

  • Sort Key: u0.updated_at DESC NULLS LAST
  • Sort Method: quicksort Memory: 25kB
28. 7.186 7.186 ↑ 1.0 1 3,593

Index Scan using clients_groupassignment_client_id_4c897251 on clients_groupassignment u0 (cost=0.42..2.64 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=3,593)

  • Index Cond: (client_id = clients_client.id)
Planning time : 1.803 ms
Execution time : 572.072 ms