explain.depesz.com

PostgreSQL's explain analyze made readable

Result: gUew

Settings
# exclusive inclusive rows x rows loops node
1. 0.004 2,951.341 ↑ 1.0 10 1

Limit (cost=21,024,979.19..21,024,979.22 rows=10 width=76) (actual time=2,951.338..2,951.341 rows=10 loops=1)

2.          

CTE ct

3. 374.305 2,547.332 ↑ 17.7 1,000,010 1

Recursive Union (cost=0.00..20,290,183.86 rows=17,659,257 width=76) (actual time=0.031..2,547.332 rows=1,000,010 loops=1)

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

Seq Scan on comment c1 (cost=0.00..25,834.12 rows=999,977 width=76) (actual time=0.027..175.619 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: 6
5. 9.700 1,997.408 ↑ 832,964.0 2 4

Merge Join (cost=1,909,463.84..1,991,116.46 rows=1,665,928 width=76) (actual time=499.348..499.352 rows=2 loops=4)

  • Merge Cond: (ct_1.id = comment.parent_id)
6. 375.096 504.268 ↑ 3,333,256.7 3 4

Sort (cost=1,704,437.83..1,729,437.26 rows=9,999,770 width=12) (actual time=126.066..126.067 rows=3 loops=4)

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

WorkTable Scan on ct ct_1 (cost=0.00..199,995.40 rows=9,999,770 width=12) (actual time=0.005..32.293 rows=250,002 loops=4)

8. 0.012 1,483.440 ↑ 166,668.3 6 4

Materialize (cost=205,026.01..210,026.06 rows=1,000,010 width=72) (actual time=370.859..370.860 rows=6 loops=4)

9. 926.464 1,483.428 ↑ 166,668.3 6 4

Sort (cost=205,026.01..207,526.04 rows=1,000,010 width=72) (actual time=370.856..370.857 rows=6 loops=4)

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

Seq Scan on comment (cost=0.00..23,334.10 rows=1,000,010 width=72) (actual time=0.012..139.241 rows=1,000,010 loops=4)

11. 97.302 2,951.337 ↑ 1,765,925.7 10 1

Sort (cost=734,795.33..778,943.48 rows=17,659,257 width=76) (actual time=2,951.336..2,951.337 rows=10 loops=1)

  • Sort Key: ct.created_date DESC
  • Sort Method: top-N heapsort Memory: 26kB
12. 2,854.035 2,854.035 ↑ 17.7 1,000,010 1

CTE Scan on ct (cost=0.00..353,185.14 rows=17,659,257 width=76) (actual time=0.036..2,854.035 rows=1,000,010 loops=1)

Planning time : 1.094 ms
Execution time : 2,968.693 ms