explain.depesz.com

PostgreSQL's explain analyze made readable

Result: Klvt

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

Sort (cost=1,710,768.28..1,713,210.24 rows=976,784 width=693) (actual time=7,836.911..7,886.775 rows=164,058 loops=1)

  • Sort Key: main_calculation.created_at DESC
  • Sort Method: external merge Disk: 79,056kB
2. 1,260.753 7,573.189 ↑ 6.0 164,058 1

GroupAggregate (cost=657,269.57..1,012,632.60 rows=976,784 width=693) (actual time=4,975.793..7,573.189 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: 812,726
3. 1,379.547 6,312.436 ↓ 1.0 3,604,870 1

Merge Left Join (cost=657,269.57..958,550.21 rows=3,545,164 width=685) (actual time=3,087.428..6,312.436 rows=3,604,870 loops=1)

  • Merge Cond: (main_calculation.id = main_result.calculation_id)
4. 652.333 652.333 ↑ 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.004..652.333 rows=976,784 loops=1)

5. 456.697 4,280.556 ↓ 1.0 3,554,425 1

Materialize (cost=657,265.53..674,991.35 rows=3,545,164 width=16) (actual time=3,087.420..4,280.556 rows=3,554,425 loops=1)

6. 2,626.323 3,823.859 ↓ 1.0 3,554,425 1

Sort (cost=657,265.53..666,128.44 rows=3,545,164 width=16) (actual time=3,087.418..3,823.859 rows=3,554,425 loops=1)

  • Sort Key: main_result.calculation_id
  • Sort Method: external merge Disk: 65,496kB
7. 564.748 1,197.536 ↓ 1.0 3,554,425 1

Merge Left Join (cost=0.85..150,420.40 rows=3,545,164 width=16) (actual time=0.014..1,197.536 rows=3,554,425 loops=1)

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

Index Only Scan using result_calculation on main_result (cost=0.43..107,821.89 rows=3,545,164 width=16) (actual time=0.011..467.479 rows=3,547,513 loops=1)

  • Heap Fetches: 0
9. 165.309 165.309 ↑ 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.002..165.309 rows=378,117 loops=1)