Thread

  1. [PATCH] Make skipped sort explicit in EXPLAIN ANALYZE

    Marti Raudsepp <marti@juffo.org> — 2012-05-25T13:30:01Z

    Hi,
    
    This is just a small clarity improvement. tuplesort_performsort()
    skips sorting entirely when the result set has 0 or 1 tuples, but
    EXPLAIN still says it's using "quicksort". The patch changes that to
    "skipped"
    
    For example:
    
    db=# explain analyze select * from now() order by 1;
     Sort  (cost=0.02..0.03 rows=1 width=8) (actual time=0.126..0.126
    rows=1 loops=1)
       Sort Key: now
       Sort Method: skipped  Memory: 25kB
       ->  Function Scan on now  (cost=0.00..0.01 rows=1 width=8) (actual
    time=0.032..0.033 rows=1 loops=1)
    
    Patch attached.
    
    Regards,
    Marti
    
  2. Re: [PATCH] Make skipped sort explicit in EXPLAIN ANALYZE

    Tom Lane <tgl@sss.pgh.pa.us> — 2012-05-25T13:49:18Z

    Marti Raudsepp <marti@juffo.org> writes:
    > This is just a small clarity improvement. tuplesort_performsort()
    > skips sorting entirely when the result set has 0 or 1 tuples, but
    > EXPLAIN still says it's using "quicksort". The patch changes that to
    > "skipped"
    
    I'm not convinced this is an improvement; it's just one more value
    to confuse people with.  And any implementation of quicksort is likely
    to have a fast exit path for 0 or 1 item, so I don't think the existing
    display is incorrect either.
    
    			regards, tom lane
    
    
  3. Re: [PATCH] Make skipped sort explicit in EXPLAIN ANALYZE

    Marti Raudsepp <marti@juffo.org> — 2012-05-25T14:19:28Z

    On Fri, May 25, 2012 at 4:49 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
    > I'm not convinced this is an improvement; it's just one more value
    > to confuse people with.
    
    I understand where you're coming from, but personally I think the
    current output is more confusing: "Gee Postgres is stupid, it's
    sorting when there's nothing to sort!"
    
    But let's wait for a third opinion.
    
    Regards,
    Marti
    
    
  4. Re: [PATCH] Make skipped sort explicit in EXPLAIN ANALYZE

    Peter Geoghegan <peter@2ndquadrant.com> — 2012-05-25T14:39:24Z

    On 25 May 2012 15:19, Marti Raudsepp <marti@juffo.org> wrote:
    > I understand where you're coming from, but personally I think the
    > current output is more confusing: "Gee Postgres is stupid, it's
    > sorting when there's nothing to sort!"
    >
    > But let's wait for a third opinion.
    
    I agree with Tom. The idea that you "sort when there's nothing to
    sort" is not confusing. Textbook implementations of recursive sorting
    algorithms explicitly have a notion of sorting one element, by simply
    recognising that one element must already be sorted. For example, look
    at the quicksort pseudocode here:
    
    http://en.wikipedia.org/wiki/Quicksort
    
    -- 
    Peter Geoghegan       http://www.2ndQuadrant.com/
    PostgreSQL Development, 24x7 Support, Training and Services