explain.depesz.com

PostgreSQL's explain analyze made readable

Result: QTeB

Settings
# exclusive inclusive rows x rows loops node
1. 0.276 129.115 ↓ 1.0 468 1

Hash Join (cost=62,932.06..642,551.08 rows=459 width=68) (actual time=3.826..129.115 rows=468 loops=1)

  • Hash Cond: ((m.brand)::text = (top.brand)::text)
2.          

CTE managers

3. 0.297 1.426 ↓ 1.0 468 1

Nested Loop (cost=0.41..1,466.31 rows=459 width=40) (actual time=0.021..1.426 rows=468 loops=1)

4. 0.193 0.193 ↓ 1.0 468 1

Seq Scan on partners_partnermanager m_1 (cost=0.00..27.74 rows=459 width=8) (actual time=0.008..0.193 rows=468 loops=1)

  • Filter: is_hired
  • Rows Removed by Filter: 419
5. 0.936 0.936 ↑ 1.0 1 468

Index Scan using profile_userconfig_user_id_key on profile_userconfig p (cost=0.41..3.13 rows=1 width=10) (actual time=0.002..0.002 rows=1 loops=468)

  • Index Cond: (user_id = m_1.user_id)
6.          

CTE top_performer

7. 0.004 3.772 ↑ 100.0 2 1

Subquery Scan on m_2 (cost=10.33..61,459.25 rows=200 width=64) (actual time=2.789..3.772 rows=2 loops=1)

8. 0.091 1.618 ↑ 100.0 2 1

HashAggregate (cost=10.33..12.33 rows=200 width=32) (actual time=1.616..1.618 rows=2 loops=1)

  • Group Key: managers.brand
9. 1.527 1.527 ↓ 1.0 468 1

CTE Scan on managers (cost=0.00..9.18 rows=459 width=32) (actual time=0.000..1.527 rows=468 loops=1)

10.          

SubPlan (forSubquery Scan)

11. 0.004 2.150 ↑ 1.0 1 2

Limit (cost=304.60..307.22 rows=1 width=32) (actual time=1.073..1.075 rows=1 loops=2)

12. 0.010 2.146 ↑ 1.0 1 2

Nested Loop (cost=304.60..307.22 rows=1 width=32) (actual time=1.073..1.073 rows=1 loops=2)

13. 0.002 2.124 ↑ 1.0 1 2

Nested Loop (cost=304.32..306.36 rows=1 width=4) (actual time=1.062..1.062 rows=1 loops=2)

14. 0.000 2.108 ↑ 1.0 1 2

Limit (cost=304.05..304.05 rows=1 width=12) (actual time=1.054..1.054 rows=1 loops=2)

15. 0.032 2.108 ↑ 92.0 1 2

Sort (cost=304.05..304.28 rows=92 width=12) (actual time=1.053..1.054 rows=1 loops=2)

  • Sort Key: (count(*)) DESC
  • Sort Method: top-N heapsort Memory: 25kB
16. 0.056 2.076 ↑ 4.2 22 2

HashAggregate (cost=302.67..303.59 rows=92 width=12) (actual time=1.035..1.038 rows=22 loops=2)

  • Group Key: c.account_manager_id
17. 0.162 2.020 ↑ 1.0 106 2

Nested Loop (cost=0.72..302.14 rows=106 width=4) (actual time=0.205..1.010 rows=106 loops=2)

18. 0.044 0.862 ↑ 1.0 166 2

Nested Loop (cost=0.43..219.95 rows=170 width=8) (actual time=0.015..0.431 rows=166 loops=2)

19. 0.154 0.154 ↑ 1.0 166 2

Index Only Scan using idx_reactivated_partner_stat_data on partners_partnerstatdata sd (cost=0.14..9.67 rows=170 width=4) (actual time=0.008..0.077 rows=166 loops=2)

  • Heap Fetches: 124
20. 0.664 0.664 ↑ 1.0 1 332

Index Only Scan using partners_partner_pkey on partners_partner p_1 (cost=0.29..1.24 rows=1 width=4) (actual time=0.002..0.002 rows=1 loops=332)

  • Index Cond: (id = sd.partner_id)
  • Heap Fetches: 70
21. 0.996 0.996 ↑ 1.0 1 332

Index Scan using partners_partnercontract_4e98b6eb on partners_partnercontract c (cost=0.29..0.47 rows=1 width=8) (actual time=0.003..0.003 rows=1 loops=332)

  • Index Cond: (partner_id = p_1.id)
  • Filter: ((brand)::text = (m_2.brand)::text)
  • Rows Removed by Filter: 1
22. 0.014 0.014 ↑ 1.0 1 2

Index Scan using partners_partnermanager_pkey on partners_partnermanager (cost=0.28..2.29 rows=1 width=8) (actual time=0.007..0.007 rows=1 loops=2)

  • Index Cond: (id = c.account_manager_id)
23. 0.012 0.012 ↑ 1.0 1 2

Index Scan using auth_user_pkey on auth_user u (cost=0.28..0.87 rows=1 width=20) (actual time=0.006..0.006 rows=1 loops=2)

  • Index Cond: (id = partners_partnermanager.user_id)
24. 0.104 0.104 ↓ 1.0 468 1

CTE Scan on managers m (cost=0.00..9.18 rows=459 width=40) (actual time=0.023..0.104 rows=468 loops=1)

25. 0.005 3.779 ↑ 100.0 2 1

Hash (cost=4.00..4.00 rows=200 width=64) (actual time=3.779..3.779 rows=2 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
26. 3.774 3.774 ↑ 100.0 2 1

CTE Scan on top_performer top (cost=0.00..4.00 rows=200 width=64) (actual time=2.789..3.774 rows=2 loops=1)

27.          

SubPlan (forHash Join)

28. 4.680 124.956 ↑ 1.0 1 468

Aggregate (cost=1,262.72..1,262.73 rows=1 width=32) (actual time=0.267..0.267 rows=1 loops=468)

29. 0.000 120.276 ↑ 5.1 90 468

Nested Loop (cost=0.70..1,261.57 rows=460 width=6) (actual time=0.003..0.257 rows=90 loops=468)

30. 37.440 37.440 ↑ 5.2 90 468

Index Scan using partners_partnercontract_6bc80cbd on partners_partnercontract c_1 (cost=0.41..449.89 rows=464 width=4) (actual time=0.002..0.080 rows=90 loops=468)

  • Index Cond: (account_manager_id = m.manager_id)
31. 84.310 84.310 ↑ 1.0 1 42,155

Index Scan using partners_partnercontractstatdata_pkey on partners_partnercontractstatdata sd_1 (cost=0.29..1.75 rows=1 width=10) (actual time=0.002..0.002 rows=1 loops=42,155)

  • Index Cond: (contract_id = c_1.id)
Planning time : 1.546 ms
Execution time : 129.340 ms