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 1iJL2H-0000ux-AT for pgsql-bugs@arkaria.postgresql.org; Sat, 12 Oct 2019 17:18:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iJL1I-0008AI-3L for pgsql-bugs@arkaria.postgresql.org; Sat, 12 Oct 2019 17:17:32 +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 1iJL1H-00089z-Qm for pgsql-bugs@lists.postgresql.org; Sat, 12 Oct 2019 17:17:31 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iJL1A-0003cq-Vk for pgsql-bugs@lists.postgresql.org; Sat, 12 Oct 2019 17:17:31 +0000 Received: from [192.168.127.1] (port=10946 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtp (Exim 4.92.3 (FreeBSD)) (envelope-from ) id 1iJL18-0009iF-H6; Sat, 12 Oct 2019 17:17:22 +0000 Received: from localhost ([127.0.0.1]:25261 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.92.1 (FreeBSD)) (envelope-from ) id 1iJL17-0009LA-PE; Sat, 12 Oct 2019 17:17:21 +0000 From: Andrew Gierth To: cfederico87@gmail.com Cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16053: Query planner performance regression in sql query with multiple CTE in v12 In-Reply-To: <16053-c96a1db8b5cbffde@postgresql.org> (PG Bug reporting form's message of "Sat, 12 Oct 2019 16:26:06 +0000") Message-ID: <87eezhx5ck.fsf@news-spur.riddles.org.uk> References: <16053-c96a1db8b5cbffde@postgresql.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (berkeley-unix) Date: Sat, 12 Oct 2019 18:17:21 +0100 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >>>>> "PG" == PG Bug reporting form writes: PG> After upgrading to v12 from v11.4 I've noticed one of the queries PG> run by an application has a significant performance degradation. PG> I've managed to create a toy db that illustrates the issue. PG> Following is a link of the db and the query in question (there PG> seems to be no way to attach a file from the web form. If I should PG> upload them somewhere else let me know) PG> https://www.dropbox.com/s/6n3ctdn2zohoann/toy-db_and_query.zip?dl=0 You could at least have included the query in the message. What seems to be happening here looks to me more down to chance than to any bug. In v11, the join order is constrained by the CTEs, whereas in v12 it is not; the misplan is the result of a mis-estimated 1-row result from a subpath that may not have been considered under v11. -- Andrew (irc:RhodiumToad)