EXPLAIN ANALYZE output weird for Top-N Sort - Mailing list pgsql-hackers

From Simon Riggs
Subject EXPLAIN ANALYZE output weird for Top-N Sort
Date
Msg-id CA+U5nMJyQjudpRoQ7+scT70gYd1osdkBh=pfyG3awmz6n7qXDA@mail.gmail.com
Whole thread Raw
Responses Re: EXPLAIN ANALYZE output weird for Top-N Sort  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: EXPLAIN ANALYZE output weird for Top-N Sort  (Jeremy Harris <jgh@wizmail.org>)
List pgsql-hackers
Limit  (cost=.... rows=20 width=175) (actual time=.... rows=20 loops=1)  ->  Sort  (cost=.... rows=568733 width=175)
(actualtime=....
 
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



pgsql-hackers by date:

Previous
From: David G Johnston
Date:
Subject: Re: [GENERAL] Performance issue with libpq prepared queries on 9.3 and 9.4
Next
From: Tom Lane
Date:
Subject: Re: Re: [GENERAL] Performance issue with libpq prepared queries on 9.3 and 9.4