Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cBr9i-0007kD-ME for pgsql-bugs@arkaria.postgresql.org; Tue, 29 Nov 2016 22:45:42 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1cBr9h-0000uf-I0 for pgsql-bugs@arkaria.postgresql.org; Tue, 29 Nov 2016 22:45:41 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cBq8P-0007Yf-3O for pgsql-bugs@postgresql.org; Tue, 29 Nov 2016 21:40:17 +0000 Received: from smtp66.ord1c.emailsrvr.com ([108.166.43.66]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1cBq8H-0004Mm-VL for pgsql-bugs@postgresql.org; Tue, 29 Nov 2016 21:40:16 +0000 Received: from smtp17.relay.ord1c.emailsrvr.com (localhost [127.0.0.1]) by smtp17.relay.ord1c.emailsrvr.com (SMTP Server) with ESMTP id 61F1F6014D; Tue, 29 Nov 2016 16:40:00 -0500 (EST) X-Auth-ID: blake@rcmail.com Received: by smtp17.relay.ord1c.emailsrvr.com (Authenticated sender: blake-AT-rcmail.com) with ESMTPSA id 303ED60163; Tue, 29 Nov 2016 16:40:00 -0500 (EST) X-Sender-Id: blake@rcmail.com Received: from [10.5.31.41] ([UNAVAILABLE]. [45.73.149.202]) (using TLSv1.2 with cipher DHE-RSA-AES256-SHA256) by 0.0.0.0:465 (trex/5.7.12); Tue, 29 Nov 2016 16:40:00 -0500 User-Agent: Microsoft-MacOutlook/f.1c.1.161117 Date: Tue, 29 Nov 2016 16:39:59 -0500 Subject: Re: parallel sequential scan returns extraneous rows From: Michael Day To: Tom Lane CC: Message-ID: <6388A361-BE20-44B5-9F07-58ABDE24DFAD@rcmail.com> Thread-Topic: [BUGS] parallel sequential scan returns extraneous rows References: <22908.1480436353@sss.pgh.pa.us> In-Reply-To: <22908.1480436353@sss.pgh.pa.us> Mime-version: 1.0 Content-type: text/plain; charset="UTF-8" Content-transfer-encoding: quoted-printable X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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 =3D 0; select count(*) from users u=20 join address a on (a.users_id =3D u.id)=20 where exists (select 1 from address where users_id =3D u.id); set max_parallel_workers_per_gather =3D 1; select count(*) from users u=20 join address a on (a.users_id =3D u.id)=20 where exists (select 1 from address where users_id =3D u.id); On 11/29/16, 11:19 AM, "Tom Lane" wrote: Michael Day 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 us= ing parallel sequential scan plans are incorrect (though I haven=E2=80=99t = dug sufficiently to know in what ways). See below for an example of the is= sue. =20=20=20=20 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. =20=20=20=20 I couldn't reproduce this in a bit of trying, however. Can you come up with a self-contained test case? =20=20=20=20 regards, tom lane =20=20=20=20 --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs