explain.depesz.com

PostgreSQL's explain analyze made readable

Result: YSWe

Settings
# exclusive inclusive rows x rows loops node
1. 303.637 7,839.860 ↑ 6.0 164,058 1

Sort (cost=1,711,229.35..1,713,671.31 rows=976,784 width=693) (actual time=7,790.403..7,839.860 rows=164,058 loops=1)

  • Sort Key: main_calculation.created_at DESC
  • Sort Method: external merge Disk: 79056kB
2. 1,252.469 7,536.223 ↑ 6.0 164,058 1

GroupAggregate (cost=657,660.18..1,013,093.67 rows=976,784 width=693) (actual time=5,018.394..7,536.223 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,347.584 6,283.754 ↓ 1.0 3,604,870 1

Merge Left Join (cost=657,660.18..958,981.92 rows=3,547,513 width=685) (actual time=3,124.653..6,283.754 rows=3,604,870 loops=1)

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

Index Scan using "idx_457863_PRIMARY" on main_calculation (cost=0.42..236,802.35 rows=976,784 width=677) (actual time=0.005..645.493 rows=976,784 loops=1)

5. 444.625 4,290.677 ↓ 1.0 3,554,425 1

Materialize (cost=657,656.13..675,393.69 rows=3,547,513 width=16) (actual time=3,124.643..4,290.677 rows=3,554,425 loops=1)

6. 2,643.837 3,846.052 ↓ 1.0 3,554,425 1

Sort (cost=657,656.13..666,524.91 rows=3,547,513 width=16) (actual time=3,124.639..3,846.052 rows=3,554,425 loops=1)

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

Merge Left Join (cost=0.85..150,461.51 rows=3,547,513 width=16) (actual time=0.017..1,202.215 rows=3,554,425 loops=1)

  • Merge Cond: (main_result.id = policy_agreement.result_id)
8. 463.388 463.388 ↑ 1.0 3,547,513 1

Index Only Scan using result_calculation on main_result (cost=0.43..107,857.12 rows=3,547,513 width=16) (actual time=0.014..463.388 rows=3,547,513 loops=1)

  • Heap Fetches: 0
9. 168.540 168.540 ↑ 1.0 378,117 1

Index Scan using policy_result on policy_agreement (cost=0.42..29,009.14 rows=378,117 width=16) (actual time=0.003..168.540 rows=378,117 loops=1)

Planning time : 0.661 ms
Execution time : 7,865.700 ms