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 1rIbLg-009gka-J6 for pgsql-admin@arkaria.postgresql.org; Wed, 27 Dec 2023 21:21:56 +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 1rIbLf-009eKg-AD for pgsql-admin@arkaria.postgresql.org; Wed, 27 Dec 2023 21:21:55 +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 1rIbLe-009eKX-VF for pgsql-admin@lists.postgresql.org; Wed, 27 Dec 2023 21:21:54 +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 1rIbLc-00CUz5-Jq for pgsql-admin@lists.postgresql.org; Wed, 27 Dec 2023 21:21:53 +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 3BRLLpXM2746246; Wed, 27 Dec 2023 16:21:52 -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: Comments: In-reply-to jian xu message dated "Wed, 27 Dec 2023 21:15:08 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <2746244.1703712111.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 27 Dec 2023 16:21:51 -0500 Message-ID: <2746245.1703712111@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk jian xu writes: > Sorry, we figured out that the PostgreSQL.conf has the nestloop disabled= =C2=85.that=C2=92s why It picked merge join by default > But it might be still very helpful if there is a way to show how the pla= n is generated , or some debug information about the plan generating, for = example in this case, if we can debug the plan and see nestloop is disable= , it will be easy for us figure out the problem. In supported releases of PG, there's the EXPLAIN (SETTINGS) option, which will print the values of any non-default settings that affect planning. Of course, you have to remember to use that, but it does respond to your point. regards, tom lane