explain.depesz.com

PostgreSQL's explain analyze made readable

Result: sGYu : window function

Settings
# exclusive inclusive rows x rows loops node
1. 95.510 1,886.785 ↑ 4,987.5 2 1

Subquery Scan on t (cost=130,399.27..146,899.27 rows=9,975 width=32) (actual time=1,294.205..1,886.785 rows=2 loops=1)

  • Output: t.c1, t.c2, t.count, t.rn_asc, t.rn_desc
  • Filter: ((1 = t.rn_asc) OR (1 = t.rn_desc))
  • Rows Removed by Filter: 999,998
  • Buffers: shared hit=1,005,296, temp read=5,036 written=5,039
2. 403.540 1,791.275 ↑ 1.0 1,000,000 1

WindowAgg (cost=130,399.27..139,899.27 rows=1,000,000 width=32) (actual time=1,294.204..1,791.275 rows=1,000,000 loops=1)

  • Output: t_1.c1, t_1.c2, t_1.count, row_number() OVER (?), (row_number() OVER (?))
  • Buffers: shared hit=1,005,296, temp read=5,036 written=5,039
3. 486.241 1,387.735 ↑ 1.0 1,000,000 1

Sort (cost=130,399.27..132,899.27 rows=1,000,000 width=24) (actual time=1,294.186..1,387.735 rows=1,000,000 loops=1)

  • Output: t_1.count, t_1.c1, t_1.c2, (row_number() OVER (?))
  • Sort Key: t_1.count
  • Sort Method: external merge Disk: 40,288kB
  • Buffers: shared hit=1,005,296, temp read=5,036 written=5,039
4. 374.384 901.494 ↑ 1.0 1,000,000 1

WindowAgg (cost=0.42..19,021.42 rows=1,000,000 width=24) (actual time=0.022..901.494 rows=1,000,000 loops=1)

  • Output: t_1.count, t_1.c1, t_1.c2, row_number() OVER (?)
  • Buffers: shared hit=1,005,296
5. 527.110 527.110 ↑ 1.0 1,000,000 1

Index Scan Backward using the_table_count_idx on stuff.the_table t_1 (cost=0.42..12,021.42 rows=1,000,000 width=16) (actual time=0.013..527.110 rows=1,000,000 loops=1)

  • Output: t_1.count, t_1.c1, t_1.c2
  • Buffers: shared hit=1,005,296
Planning time : 0.113 ms
Execution time : 1,892.791 ms