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 1qMu8h-003ZE4-I5 for pgsql-hackers@arkaria.postgresql.org; Fri, 21 Jul 2023 17:42:03 +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 1qMu8f-005Q2b-Tz for pgsql-hackers@arkaria.postgresql.org; Fri, 21 Jul 2023 17:42:01 +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 1qMu8f-005Q0r-Jv for pgsql-hackers@lists.postgresql.org; Fri, 21 Jul 2023 17:42:01 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qMu8d-000ijt-7m for pgsql-hackers@lists.postgresql.org; Fri, 21 Jul 2023 17:42:00 +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 36LHfua4971651; Fri, 21 Jul 2023 13:41:56 -0400 From: Tom Lane To: Gurjeet Singh cc: Ahmed Ibrahim , pgsql-hackers@lists.postgresql.org Subject: Re: Issue in _bt_getrootheight In-reply-to: References: Comments: In-reply-to Gurjeet Singh message dated "Wed, 19 Jul 2023 20:45:41 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <971649.1689961316.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 21 Jul 2023 13:41:56 -0400 Message-ID: <971650.1689961316@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Gurjeet Singh writes: > Please see attached the patch that does this. Let me know if this patch = helps. I don't like this patch one bit, because it adds a lot of overhead (i.e., an extra index_open/close cycle for every btree index in every query) to support a tiny minority use-case. How come we don't already know whether the index is hypothetical at the point where _bt_getrootheight is called now? Actually, looking at the existing comment at the call site: /* * Allow a plugin to editorialize on the info we obtained from the * catalogs. Actions might include altering the assumed relation size= , * removing an index, or adding a hypothetical index to the indexlist. */ if (get_relation_info_hook) (*get_relation_info_hook) (root, relationObjectId, inhparent, rel)= ; reminds me that the design intention was that hypothetical indexes would get added to the list by get_relation_info_hook itself. If that's not how the index adviser is operating, maybe we need to have a discussion about that. regards, tom lane