Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hwbBb-0008Vn-Mr for pgsql-bugs@arkaria.postgresql.org; Sat, 10 Aug 2019 23:54:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hwbBX-0002HK-Tc for pgsql-bugs@arkaria.postgresql.org; Sat, 10 Aug 2019 23:54:07 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1hwbBX-0002Dk-Kc for pgsql-bugs@lists.postgresql.org; Sat, 10 Aug 2019 23:54:07 +0000 Received: from lb3-smtp-cloud7.xs4all.net ([194.109.24.31]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hwbBS-0007Xh-QV for pgsql-bugs@lists.postgresql.org; Sat, 10 Aug 2019 23:54:06 +0000 Received: from webmailclassic.xs4all.nl ([IPv6:2001:888:0:22:194:109:20:207]) by smtp-cloud7.xs4all.net with ESMTPA id wbBRhF0qyur8TwbBRheqYF; Sun, 11 Aug 2019 01:54:01 +0200 Received: from 2001:983:39b6:1:3848:f651:5e20:ac31 by webmailclassic.xs4all.nl with HTTP (HTTP/1.1 POST); Sun, 11 Aug 2019 01:54:01 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Sun, 11 Aug 2019 01:54:01 +0200 From: Erik Rijkers To: ladayaroslav@yandex.ru, pgsql-bugs@lists.postgresql.org Cc: PG Bug reporting form Subject: Re: BUG #15947: Worse plan is chosen after giving the planner more freedom (partitionwise join) In-Reply-To: <15947-c242874031212a07@postgresql.org> References: <15947-c242874031212a07@postgresql.org> Message-ID: X-Sender: er@xs4all.nl User-Agent: XS4ALL Webmail X-CMAE-Envelope: MS4wfDq3L36fByc5AS+vRfkYyg54z2nBi9DFMcvvhiaY6mDMhON3oDTN24lQ2BxmfjvipuVKPDEQASv/jBM663wxOkjQ8cZ+JFC7e0SLc26tQwXkI6LfTu5v /WshpiZqzrl0a0FU+Hjo7AIWKHwQ1ek8mRxCvbi2aJi0rZmNAyVkGelkK766dqktugtLPMY9U40fWXvamYmpOeOfLaQax7jp0QYwW8DvgXaQN3SjDV+KZXiO DRbBfMnSlCYcIIK69Ztr4womIORZQRxYvQ4HblzVXkcTfFeS+j71zSO/oOiDGhwp List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2019-08-11 00:28, PG Bug reporting form wrote: > The following bug has been logged on the website: > > Bug reference: 15947 > I'm trying the following query: > > EXPLAIN > SELECT COUNT(*) > FROM sc > WHERE EXISTS ( > SELECT 1 > FROM sg > WHERE sc.id = sg.sc_fk > AND sc.a = sg.a > AND sc.o = sg.o > AND sc.sl = sg.sl > ); > > Which produces the plan with this cost estimation (top node): > -- Aggregate (cost=147.25..147.26 rows=1 width=8) > > But after: > SET enable_partitionwise_join = true; > > The new plan is more expensive: > -- Aggregate (cost=175.00..175.01 rows=1 width=8) > > This shouldn't be happening, right? Why not? The 'worse plan' cnsistently executes faster. I don't think the cost units of different queries can/should be compared as if they are the same.