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 1uA8CR-00B5R5-3p for pgsql-performance@arkaria.postgresql.org; Wed, 30 Apr 2025 14:14:11 +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 1uA8CO-00EIwN-VF for pgsql-performance@arkaria.postgresql.org; Wed, 30 Apr 2025 14:14:10 +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 1uA8CO-00EIwE-Lf for pgsql-performance@lists.postgresql.org; Wed, 30 Apr 2025 14:14:09 +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.96) (envelope-from ) id 1uA8CN-000N5B-0J for pgsql-performance@lists.postgresql.org; Wed, 30 Apr 2025 14:14:09 +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 53UEE4me1287725; Wed, 30 Apr 2025 10:14:04 -0400 From: Tom Lane To: =?UTF-8?Q?Felipe_L=C3=B3pez_Montes?= cc: pgsql-performance@lists.postgresql.org Subject: Re: PostgreSQL Choosing Full Index Over Partial Index In-reply-to: References: <79f3cb0ac1e221012df38d7baa72463662c37095.camel@cybertec.at> <783872.1745852832@sss.pgh.pa.us> Comments: In-reply-to =?UTF-8?Q?Felipe_L=C3=B3pez_Montes?= message dated "Wed, 30 Apr 2025 11:11:14 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1287723.1746022444.1@sss.pgh.pa.us> Date: Wed, 30 Apr 2025 10:14:04 -0400 Message-ID: <1287724.1746022444@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk =?UTF-8?Q?Felipe_L=C3=B3pez_Montes?= writes: > Thanks a lot for your response Tom. > May I ask how do you debug those functions? > Or is it just that you read the code and more or less guess what should be > the value for each variable with information coming from querying Postgres > tables? The guessing was in building a test case, since you didn't provide a self-contained reproducer... Once I had a case where the estimated cost was smaller for the larger index, I just worked through the code to see where the costs diverged. It helped that I already know the structure of that code well, but there wasn't guesswork involved, other than where to set breakpoints to narrow down the source more quickly. I forgot to mention on this thread that I posted a possible fix at [1]. regards, tom lane [1] https://www.postgresql.org/message-id/870686.1745860834%40sss.pgh.pa.us