pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Day <blake@rcmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@postgresql.org
Subject: Re: parallel sequential scan returns extraneous rows
Date: Tue, 29 Nov 2016 16:39:59 -0500
Message-ID: <6388A361-BE20-44B5-9F07-58ABDE24DFAD@rcmail.com> (raw)
In-Reply-To: <22908.1480436353@sss.pgh.pa.us>
References: <D0E8A029-D1AC-42E8-979A-5DE4A77E4413@rcmail.com>
	<22908.1480436353@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

I was able to reproduce with this set of data.

create table users (id integer);
create table address (id integer, users_id integer);

insert into users select s from generate_series(1,1000000) s;
insert into address select s, s/2 from generate_series(1,2000000) s;

analyze users;
analyze address;

set max_parallel_workers_per_gather = 0;

select count(*)
from users u 
join address a on (a.users_id = u.id) 
where exists (select 1 from address where users_id = u.id);

set max_parallel_workers_per_gather = 1;

select count(*)
from users u 
join address a on (a.users_id = u.id) 
where exists (select 1 from address where users_id = u.id);


On 11/29/16, 11:19 AM, "Tom Lane" <tgl@sss.pgh.pa.us> wrote:

    Michael Day <blake@rcmail.com> writes:
    > I have found a nasty bug when using parallel sequential scans with an exists clause on postgresql 9.6.1.  I have found that the rows returned using parallel sequential scan plans are incorrect (though I haven’t dug sufficiently to know in what ways).  See below for an example of the issue.
    
    Hm, looks like a planner error: it seems to be forgetting that the join
    to "address" should be a semijoin.  "address" should either be on the
    inside of a "Semi" join (as in your first, correct-looking plan) or be
    passed through a unique-ification stage such as a HashAgg.  Clearly,
    neither thing is happening in the second plan.
    
    I couldn't reproduce this in a bit of trying, however.  Can you come
    up with a self-contained test case?
    
    			regards, tom lane
    




-- 
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 (4+ messages)  latest in thread

Message-ID: <6388A361-BE20-44B5-9F07-58ABDE24DFAD@rcmail.com>
Permalink:  ../6388A361-BE20-44B5-9F07-58ABDE24DFAD@rcmail.com/
Also on:    postgresql.org/message-id/6388A361-BE20-44B5-9F07-58ABDE24DFAD@rcmail.com

 · 

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: blake@rcmail.com, tgl@sss.pgh.pa.us
  Subject: Re: parallel sequential scan returns extraneous rows
  In-Reply-To: <6388A361-BE20-44B5-9F07-58ABDE24DFAD@rcmail.com>
  References: <D0E8A029-D1AC-42E8-979A-5DE4A77E4413@rcmail.com> <22908.1480436353@sss.pgh.pa.us> <6388A361-BE20-44B5-9F07-58ABDE24DFAD@rcmail.com>

* 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