explain.depesz.com

PostgreSQL's explain analyze made readable

Result: K2GW

Settings
# exclusive inclusive rows x rows loops node
1. 306.604 9,509.360 ↑ 6.0 164,058 1

Sort (cost=1,784,128.24..1,786,571.07 rows=977,134 width=693) (actual time=9,458.639..9,509.360 rows=164,058 loops=1)

  • Sort Key: main_calculation.created_at DESC
  • Sort Method: external merge Disk: 79056kB
2. 1,254.665 9,202.756 ↑ 6.0 164,058 1

GroupAggregate (cost=730,051.98..1,085,745.22 rows=977,134 width=693) (actual time=6,381.926..9,202.756 rows=164,058 loops=1)

  • Group Key: main_calculation.id
  • Filter: ((COALESCE(max(policy_agreement.created), main_calculation.created_at) >= '2019-10-10'::date) AND (COALESCE(max(policy_agreement.created), main_calculation.created_at) <= '2020-01-31'::date))
  • Rows Removed by Filter: 812726
3. 1,339.565 7,948.091 ↓ 1.0 3,604,870 1

Merge Left Join (cost=730,051.98..1,031,613.84 rows=3,548,803 width=685) (actual time=4,394.017..7,948.091 rows=3,604,870 loops=1)

  • Merge Cond: (main_calculation.id = main_result.calculation_id)
4. 712.353 712.353 ↑ 1.0 976,784 1

Index Scan using "idx_457863_PRIMARY" on main_calculation (cost=0.42..237,015.40 rows=977,134 width=677) (actual time=0.004..712.353 rows=976,784 loops=1)

5. 447.980 5,896.173 ↓ 1.0 3,554,425 1

Materialize (cost=730,051.55..747,795.57 rows=3,548,803 width=16) (actual time=4,394.008..5,896.173 rows=3,554,425 loops=1)

6. 3,084.931 5,448.193 ↓ 1.0 3,554,425 1

Sort (cost=730,051.55..738,923.56 rows=3,548,803 width=16) (actual time=4,394.006..5,448.193 rows=3,554,425 loops=1)

  • Sort Key: main_result.calculation_id
  • Sort Method: external merge Disk: 65496kB
7. 954.731 2,363.262 ↓ 1.0 3,554,425 1

Hash Right Join (cost=174,705.07..222,658.29 rows=3,548,803 width=16) (actual time=1,332.434..2,363.262 rows=3,554,425 loops=1)

  • Hash Cond: (policy_agreement.result_id = main_result.id)
8. 76.810 76.810 ↑ 1.0 378,117 1

Seq Scan on policy_agreement (cost=0.00..20,313.17 rows=378,117 width=16) (actual time=0.005..76.810 rows=378,117 loops=1)

9. 622.226 1,331.721 ↑ 1.0 3,547,513 1

Hash (cost=113,016.03..113,016.03 rows=3,548,803 width=16) (actual time=1,331.721..1,331.721 rows=3,547,513 loops=1)

  • Buckets: 131072 Batches: 64 Memory Usage: 3616kB
10. 709.495 709.495 ↑ 1.0 3,547,513 1

Seq Scan on main_result (cost=0.00..113,016.03 rows=3,548,803 width=16) (actual time=0.035..709.495 rows=3,547,513 loops=1)