pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: bashtanov@imap.cc
To: pgsql-bugs@postgresql.org
Subject: BUG #10816: explain analyze reports different rows counts before and after sort
Date: Mon, 30 Jun 2014 09:43:43 +0000
Message-ID: <20140630094343.15698.80138@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

The following bug has been logged on the website:

Bug reference:      10816
Logged by:          Alexey Bashtanov
Email address:      bashtanov@imap.cc
PostgreSQL version: 9.3.4
Operating system:   Ubuntu Linux 12.04
Description:        

Hello!

Please have a look at the two bottom nodes of the plan. Function scan
produces 1000 rows, then they are sorted and turn into 3201 rows! How could
this happen?

localhost/stat 13:31:19 > select version();
                                               version                      
                        
-----------------------------------------------------------------------------------------------------
 PostgreSQL 9.3.4 on i686-pc-linux-gnu, compiled by gcc (Ubuntu/Linaro
4.6.3-1ubuntu5) 4.6.3, 32-bit
(1 row)

localhost/stat 13:31:21 > set enable_hashjoin to off;
SET
localhost/stat 13:31:22 > explain analyze select * from (select k % 5 b from
generate_series(1,4000) k) l natural join generate_series(1,1000) b;
                                                            QUERY PLAN      
                                                      
-----------------------------------------------------------------------------------------------------------------------------------
 Merge Join  (cost=119.66..227.16 rows=5000 width=4) (actual
time=5.977..11.848 rows=3200 loops=1)
   Merge Cond: (((k.k % 5)) = b.b)
   ->  Sort  (cost=59.83..62.33 rows=1000 width=4) (actual time=4.571..5.825
rows=4000 loops=1)
         Sort Key: ((k.k % 5))
         Sort Method: quicksort  Memory: 221kB
         ->  Function Scan on generate_series k  (cost=0.00..10.00 rows=1000
width=4) (actual time=0.732..2.737 rows=4000 loops=1)
   ->  Sort  (cost=59.83..62.33 rows=1000 width=4) (actual time=0.878..1.942
rows=3201 loops=1)
         Sort Key: b.b
         Sort Method: quicksort  Memory: 40kB
         ->  Function Scan on generate_series b  (cost=0.00..10.00 rows=1000
width=4) (actual time=0.193..0.528 rows=1000 loops=1)
 Total runtime: 12.814 ms
(11 rows)

Regards, 
  Alexey Bashtanov


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (2+ messages)  latest in thread

Message-ID: <20140630094343.15698.80138@wrigleys.postgresql.org>
Permalink:  ../20140630094343.15698.80138@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20140630094343.15698.80138@wrigleys.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: bashtanov@imap.cc
  Subject: Re: BUG #10816: explain analyze reports different rows counts before and after sort
  In-Reply-To: <20140630094343.15698.80138@wrigleys.postgresql.org>
  References: <20140630094343.15698.80138@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox