explain.depesz.com

PostgreSQL's explain analyze made readable

Result: vfQg

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 0.000 ↓ 0.0

Sort (cost=309,286.55..309,567.54 rows=561,973 width=44) (actual rows= loops=)

  • Sort Key: ((((max((sum(p.amount))) - max((COALESCE(sum(fs.amount), '0'::numeric)))) - max((COALESCE(sum((sum(refund.amount))), '0'::numeric)))) - sum(COALESCE(stat.amount, '0'::numeric)))) DESC
  • JIT:
  • Functions: 78
  • Options: Inlining false, Optimization false, Expressions true, Deforming true
2. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=193,626.53..297,540.09 rows=561,973 width=44) (actual rows= loops=)

  • Group Key: a.id, a.employer, stat.account_id
  • Filter: ((((max((sum(p.amount))) - max((COALESCE(sum(fs.amount), '0'::numeric)))) - max((COALESCE(sum((sum(refund.amount))), '0'::numeric)))) - sum(COALESCE(stat.amount, '0'::numeric))) < '3000'::numeric)
3. 0.000 0.000 ↓ 0.0

Sort (cost=193,626.53..194,769.60 rows=2,286,140 width=111) (actual rows= loops=)

  • Sort Key: a.id, a.employer, stat.account_id
4. 0.000 0.000 ↓ 0.0

Hash Right Join (cost=29,260.83..137,552.43 rows=2,286,140 width=111) (actual rows= loops=)

  • Hash Cond: (stat.account_id = a.id)
  • Join Filter: (stat.event_date > (COALESCE(max(fs.event_date), '2019-09-01'::date)))
5. 0.000 0.000 ↓ 0.0

Gather (cost=100.00..106,070.88 rows=4,377,430 width=11) (actual rows= loops=)

  • Workers Planned: 4
6. 0.000 0.000 ↓ 0.0

Parallel Seq Scan on statistic stat (cost=0.00..62,196.57 rows=1,094,358 width=11) (actual rows= loops=)

7. 0.000 0.000 ↓ 0.0

Hash (cost=28,901.31..28,901.31 rows=5,139 width=108) (actual rows= loops=)

8. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=28,364.29..28,644.36 rows=5,139 width=108) (actual rows= loops=)

  • Group Key: a.id
9. 0.000 0.000 ↓ 0.0

Sort (cost=28,364.29..28,366.86 rows=5,139 width=81) (actual rows= loops=)

  • Sort Key: a.id
10. 0.000 0.000 ↓ 0.0

Merge Left Join (cost=25,664.75..28,300.94 rows=5,139 width=81) (actual rows= loops=)

  • Merge Cond: (p.id = refund.payment_id)
11. 0.000 0.000 ↓ 0.0

Merge Left Join (cost=25,664.69..28,071.86 rows=5,139 width=53) (actual rows= loops=)

  • Merge Cond: (p.id = fs.payment_id)
12. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.17..2,382.39 rows=5,139 width=17) (actual rows= loops=)

13. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.11..1,686.21 rows=5,139 width=13) (actual rows= loops=)

14. 0.000 0.000 ↓ 0.0

Index Scan using dream_payment_pkey on payment p (cost=0.06..1,056.05 rows=5,139 width=13) (actual rows= loops=)

  • Filter: (closed IS NOT TRUE)
15. 0.000 0.000 ↓ 0.0

Index Scan using invoice_pkey on invoice i (cost=0.06..0.12 rows=1 width=8) (actual rows= loops=)

  • Index Cond: (id = p.invoice_id)
16. 0.000 0.000 ↓ 0.0

Index Scan using account_pkey on account a (cost=0.06..0.14 rows=1 width=8) (actual rows= loops=)

  • Index Cond: (id = i.account_id)
17. 0.000 0.000 ↓ 0.0

Sort (cost=25,664.52..25,665.26 rows=1,482 width=40) (actual rows= loops=)

  • Sort Key: fs.payment_id
18. 0.000 0.000 ↓ 0.0

Subquery Scan on fs (cost=25,499.97..25,648.91 rows=1,482 width=40) (actual rows= loops=)

19. 0.000 0.000 ↓ 0.0

HashAggregate (cost=25,499.97..25,574.81 rows=1,482 width=40) (actual rows= loops=)

  • Group Key: fs_1.payment_id
20. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.09..25,377.89 rows=81,388 width=13) (actual rows= loops=)

21. 0.000 0.000 ↓ 0.0

Seq Scan on fixed_statistic fs_1 (cost=0.00..4,137.60 rows=81,388 width=13) (actual rows= loops=)

22. 0.000 0.000 ↓ 0.0

Index Scan using statistic_pkey on statistic s (cost=0.09..0.26 rows=1 width=8) (actual rows= loops=)

  • Index Cond: (id = fs_1.statistic_id)
23. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=0.06..142.20 rows=1,305 width=36) (actual rows= loops=)

  • Group Key: refund.payment_id
24. 0.000 0.000 ↓ 0.0

Index Scan using refund_payment_unique on refund (cost=0.06..75.00 rows=1,305 width=9) (actual rows= loops=)

  • Filter: (status = 'finish'::dream_refund_status)