Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qfhsr-00CoU1-8s for pgsql-performance@arkaria.postgresql.org; Mon, 11 Sep 2023 14:27:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qfhso-0012b2-M1 for pgsql-performance@arkaria.postgresql.org; Mon, 11 Sep 2023 14:27:22 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qfhso-0012ao-BD for pgsql-performance@lists.postgresql.org; Mon, 11 Sep 2023 14:27:22 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qfhsk-004SxQ-3f for pgsql-performance@postgresql.org; Mon, 11 Sep 2023 14:27:21 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 38BERDqC2563520; Mon, 11 Sep 2023 10:27:13 -0400 From: Tom Lane To: David Rowley cc: Mikhail Balayan , pgsql-performance@postgresql.org, Laurenz Albe Subject: Re: Planning time is time-consuming In-reply-to: References: <5ef3acf5733d5a8584b09eb5dd107e59aa87a075.camel@cybertec.at> Comments: In-reply-to David Rowley message dated "Mon, 11 Sep 2023 22:17:09 +1200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2563518.1694442433.1@sss.pgh.pa.us> Date: Mon, 11 Sep 2023 10:27:13 -0400 Message-ID: <2563519.1694442433@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley writes: > I'm not sure if you're asking for help here because you need planning > to be faster than it currently is, or if it's because you believe that > planning should always be faster than execution. If you think the > latter, then you're mistaken. Yeah. I don't see anything particularly troubling here. Taking circa three-quarters of a millisecond (on typical current hardware) to plan a four-way join on large tables is not unreasonable. In most cases one could expect the execution of such a query to take a good bit longer than that. I think the OP is putting too much emphasis on an edge case where execution finishes quickly because there are in fact zero rows matching the uuid restriction. BTW, in addition to the duplicative indexes, I wonder why the uuid columns being joined on aren't all of "uuid" type. While I doubt fixing that would move the needle greatly, it still seems sloppy. regards, tom lane