explain.depesz.com

PostgreSQL's explain analyze made readable

Result: MBsY

Settings
# exclusive inclusive rows x rows loops node
1. 771.537 3,853.405 ↑ 17.7 1,000,009 1

Sort (cost=25,122,910.04..25,167,058.10 rows=17,659,226 width=76) (actual time=3,754.286..3,853.405 rows=1,000,009 loops=1)

  • Sort Key: ct.depth, ct.created_date DESC
  • Sort Method: external sort Disk: 80240kB
  • Planning time: 10.799 ms
  • Execution time: 3914.678 ms
2.          

CTE ct

3. 311.061 2,596.090 ↑ 17.7 1,000,009 1

Recursive Union (cost=0.00..20,290,096.66 rows=17,659,226 width=76) (actual time=0.171..2,596.090 rows=1,000,009 loops=1)

4. 200.749 200.749 ↓ 1.0 1,000,004 1

Seq Scan on comment c1 (cost=0.00..25,834.11 rows=999,976 width=76) (actual time=0.166..200.749 rows=1,000,004 loops=1)

  • Filter: ((parent_id IS NULL) AND (deleted_date IS NULL) AND (website_page_id = 1))
  • Rows Removed by Filter: 5
5. 2.944 2,084.280 ↑ 1,665,925.0 1 4

Merge Join (cost=1,909,455.29..1,991,107.80 rows=1,665,925 width=76) (actual time=521.068..521.070 rows=1 loops=4)

  • Merge Cond: (ct_1.id = comment.parent_id)
6. 428.004 573.052 ↑ 4,999,880.0 2 4

Sort (cost=1,704,429.40..1,729,428.80 rows=9,999,760 width=12) (actual time=143.262..143.263 rows=2 loops=4)

  • Sort Key: ct_1.id
  • Sort Method: quicksort Memory: 25kB
7. 145.048 145.048 ↑ 40.0 250,002 4

WorkTable Scan on ct ct_1 (cost=0.00..199,995.20 rows=9,999,760 width=12) (actual time=0.006..36.262 rows=250,002 loops=4)

8. 0.008 1,508.284 ↑ 166,668.2 6 4

Materialize (cost=205,025.89..210,025.94 rows=1,000,009 width=72) (actual time=377.070..377.071 rows=6 loops=4)

9. 956.912 1,508.276 ↑ 166,668.2 6 4

Sort (cost=205,025.89..207,525.92 rows=1,000,009 width=72) (actual time=377.068..377.069 rows=6 loops=4)

  • Sort Key: comment.parent_id
  • Sort Method: external sort Disk: 80240kB
10. 551.364 551.364 ↑ 1.0 1,000,009 4

Seq Scan on comment (cost=0.00..23,334.09 rows=1,000,009 width=72) (actual time=0.009..137.841 rows=1,000,009 loops=4)

11. 3,081.868 3,081.868 ↑ 17.7 1,000,009 1

CTE Scan on ct (cost=0.00..353,184.52 rows=17,659,226 width=76) (actual time=0.175..3,081.868 rows=1,000,009 loops=1)