explain.depesz.com

PostgreSQL's explain analyze made readable

Result: sv6j

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

Sort (cost=1,711,896.38..1,714,339.21 rows=977,134 width=693) (actual time=7,587.055..7,636.398 rows=164,058 loops=1)

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

GroupAggregate (cost=657,858.82..1,013,513.36 rows=977,134 width=693) (actual time=4,855.243..7,336.187 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,324.029 6,110.369 ↓ 1.0 3,604,870 1

Merge Left Join (cost=657,858.82..959,398.10 rows=3,547,513 width=685) (actual time=3,017.772..6,110.369 rows=3,604,870 loops=1)

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

5. 440.209 4,167.773 ↓ 1.0 3,554,425 1

Materialize (cost=657,858.39..675,595.96 rows=3,547,513 width=16) (actual time=3,017.762..4,167.773 rows=3,554,425 loops=1)

6. 2,535.630 3,727.564 ↓ 1.0 3,554,425 1

Sort (cost=657,858.39..666,727.17 rows=3,547,513 width=16) (actual time=3,017.759..3,727.564 rows=3,554,425 loops=1)

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

Merge Left Join (cost=3.96..150,663.77 rows=3,547,513 width=16) (actual time=0.021..1,191.934 rows=3,554,425 loops=1)

  • Merge Cond: (main_result.id = policy_agreement.result_id)
8. 462.515 462.515 ↑ 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.017..462.515 rows=3,547,513 loops=1)

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

Index Scan using policy_agreement_result_id_4e18fc8e_fk_main_result_id on policy_agreement (cost=0.42..29,211.40 rows=378,117 width=16) (actual time=0.003..164.820 rows=378,117 loops=1)

Planning time : 0.702 ms
Execution time : 7,660.219 ms