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 1rIbbi-009iG9-LI for pgsql-admin@arkaria.postgresql.org; Wed, 27 Dec 2023 21:38:30 +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 1rIbbh-009tNq-C1 for pgsql-admin@arkaria.postgresql.org; Wed, 27 Dec 2023 21:38:29 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rIbbh-009tNH-0f for pgsql-admin@lists.postgresql.org; Wed, 27 Dec 2023 21:38:29 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rIbba-00CV5m-ED for pgsql-admin@lists.postgresql.org; Wed, 27 Dec 2023 21:38:27 +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 3BRLcLbJ2748482; Wed, 27 Dec 2023 16:38:21 -0500 From: Tom Lane To: jian xu cc: "pgsql-admin@lists.postgresql.org" Subject: Re: how to troubleshoot a wrong query plan In-reply-to: References: <2746245.1703712111@sss.pgh.pa.us> Comments: In-reply-to jian xu message dated "Wed, 27 Dec 2023 21:29:39 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2748480.1703713101.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 27 Dec 2023 16:38:21 -0500 Message-ID: <2748481.1703713101@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk jian xu writes: > Thanks Tom, except for setting parameters, is there any other ways to sh= ow debug information about plan generating? For example, can pg show all t= he candidate plans it searched, and the cost of each candidate plan? No, because rejected alternatives are not carried through to the point of having a displayable plan. (Trying to do so would be enormously expensive.) People have experimented with adding trace facilities that would show some details about rejected plan alternatives, but none of that has led to a facility that I'd care to use. regards, tom lane