explain.depesz.com

PostgreSQL's explain analyze made readable

Result: EZpM

Settings
# exclusive inclusive rows x rows loops node
1. 62,753.138 63,801.829 ↑ 12.7 519,020 1

Merge Right Join (cost=135,630.87..12,216,204.46 rows=6,609,720 width=422) (actual time=594.908..63,801.829 rows=519,020 loops=1)

  • Merge Cond: (pc.parent_contract_id = (COALESCE(rd.parent_contract_id, rd.contract_id)))
2.          

CTE parent_contract

3. 1.052 1.052 ↑ 1.0 2,481 1

Seq Scan on crm_contracts cc (cost=0.00..148.55 rows=2,547 width=19) (actual time=0.009..1.052 rows=2,481 loops=1)

  • Filter: (kind = 1)
  • Rows Removed by Filter: 2368
4. 1.379 3.237 ↑ 1.0 2,481 1

Sort (cost=195.03..201.40 rows=2,547 width=40) (actual time=2.530..3.237 rows=2,481 loops=1)

  • Sort Key: pc.parent_contract_id
  • Sort Method: quicksort Memory: 278kB
5. 1.858 1.858 ↑ 1.0 2,481 1

CTE Scan on parent_contract pc (cost=0.00..50.94 rows=2,547 width=40) (actual time=0.012..1.858 rows=2,481 loops=1)

6. 144.563 1,045.454 ↑ 1.0 519,020 1

Materialize (cost=135,287.29..137,882.39 rows=519,020 width=131) (actual time=592.223..1,045.454 rows=519,020 loops=1)

7. 705.211 900.891 ↑ 1.0 519,020 1

Sort (cost=135,287.29..136,584.84 rows=519,020 width=131) (actual time=592.220..900.891 rows=519,020 loops=1)

  • Sort Key: (COALESCE(rd.parent_contract_id, rd.contract_id))
  • Sort Method: external merge Disk: 53928kB
8. 195.680 195.680 ↑ 1.0 519,020 1

Seq Scan on resident_days rd (cost=0.00..15,052.20 rows=519,020 width=131) (actual time=0.006..195.680 rows=519,020 loops=1)

Planning time : 0.276 ms
Execution time : 63,865.349 ms