EXPLAIN ANALYZE output weird for Top-N Sort

From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: EXPLAIN ANALYZE output weird for Top-N Sort
Date: 2014-11-14 00:46:30
Message-ID: CA+U5nMJyQjudpRoQ7+scT70gYd1osdkBh=pfyG3awmz6n7qXDA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Limit (cost=.... rows=20 width=175) (actual time=.... rows=20 loops=1)
-> Sort (cost=.... rows=568733 width=175) (actual time=....
rows=20 loops=1)
Sort Method: top-N heapsort

The Sort estimate shows 568733 rows, whereas the actual rows are 20.

Both are correct, in a way.

The node feeding the Sort shows an actual of 379114 rows.

If we are looking at rows returned, then the Sort node estimate should say 20
If we are looking at rows processed, then the Sort node should have
actual rows=379114

I think we should say the latter; i,e, the Sort node should report
379114 rows, not 20 rows.

Thoughts?

--
Simon Riggs http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2014-11-14 00:47:24 Re: Re: [GENERAL] Performance issue with libpq prepared queries on 9.3 and 9.4
Previous Message David G Johnston 2014-11-14 00:43:45 Re: [GENERAL] Performance issue with libpq prepared queries on 9.3 and 9.4