explain.depesz.com

PostgreSQL's explain analyze made readable

Result: I7vH

Settings
# exclusive inclusive rows x rows loops node
1. 0.201 547.879 ↑ 1.0 1 1

Aggregate (cost=405,815.68..405,815.69 rows=1 width=8) (actual time=547.879..547.879 rows=1 loops=1)

2. 0.435 547.678 ↓ 3,468.0 3,468 1

Unique (cost=405,815.66..405,815.67 rows=1 width=4) (actual time=547.005..547.678 rows=3,468 loops=1)

3. 1.315 547.243 ↓ 3,470.0 3,470 1

Sort (cost=405,815.66..405,815.67 rows=1 width=4) (actual time=547.004..547.243 rows=3,470 loops=1)

  • Sort Key: clients_client.id
  • Sort Method: quicksort Memory: 259kB
4. 32.606 545.928 ↓ 3,470.0 3,470 1

Nested Loop Semi Join (cost=19,798.98..405,815.65 rows=1 width=4) (actual time=75.046..545.928 rows=3,470 loops=1)

5. 126.190 237.322 ↓ 1.5 92,000 1

Hash Join (cost=19,798.28..32,507.42 rows=59,873 width=8) (actual time=74.692..237.322 rows=92,000 loops=1)

  • Hash Cond: (clients_groupassignment.client_id = clients_client.id)
6. 36.625 36.625 ↑ 1.0 468,973 1

Seq Scan on clients_groupassignment (cost=0.00..11,453.88 rows=478,188 width=8) (actual time=0.007..36.625 rows=468,973 loops=1)

7. 15.481 74.507 ↓ 1.0 92,013 1

Hash (cost=18,667.73..18,667.73 rows=90,444 width=4) (actual time=74.507..74.507 rows=92,013 loops=1)

  • Buckets: 131072 Batches: 1 Memory Usage: 4259kB
8. 59.026 59.026 ↓ 1.0 92,013 1

Index Scan using clients_client_brokerage_id on clients_client (cost=0.42..18,667.73 rows=90,444 width=4) (actual time=0.019..59.026 rows=92,013 loops=1)

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

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

10. 171.575 276.000 ↓ 0.0 0 92,000

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

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

SubPlan (for Index Scan)

12. 23.757 104.425 ↑ 1.0 1 20,885

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

13. 2.872 62.655 ↑ 1.0 1 20,885

Nested Loop (cost=0.71..5.15 rows=1 width=8) (actual time=0.003..0.003 rows=1 loops=20,885)

14. 41.770 41.770 ↑ 1.0 1 20,885

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=20,885)

  • Index Cond: (client_id = v0.client_id)
  • Heap Fetches: 15774
15. 18.013 18.013 ↑ 1.0 1 18,013

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

  • Index Cond: (id = u3.user_id)
  • Heap Fetches: 17153
16. 18.013 18.013 ↑ 1.0 1 18,013

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,013)

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

Hash Join (cost=1,930.90..19,841.38 rows=571,474 width=8) (never executed)

  • Hash Cond: (u3_1.user_id = u0_1.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,611.73..1,611.73 rows=25,534 width=12) (never executed)

20. 0.000 0.000 ↓ 0.0 0

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

  • Hash Cond: (u1_1.user_id = u0_1.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=782.65..782.65 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_1 (cost=0.29..782.65 rows=28,296 width=4) (never executed)

  • Heap Fetches: 0
24. 3.472 3.472 ↑ 1.0 1 3,472

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,472)

  • Index Cond: (id = v0.group_id)
  • Filter: (company_id = 18855)
  • Rows Removed by Filter: 0
Planning time : 1.900 ms
Execution time : 547.988 ms