Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o96Dh-0003tQ-5I for pgsql-bugs@arkaria.postgresql.org; Wed, 06 Jul 2022 14:41:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o96Df-0001TK-Bp for pgsql-bugs@arkaria.postgresql.org; Wed, 06 Jul 2022 14:41:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o96Df-0001PX-3J for pgsql-bugs@lists.postgresql.org; Wed, 06 Jul 2022 14:41:35 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o96Dc-0007yN-WC for pgsql-bugs@lists.postgresql.org; Wed, 06 Jul 2022 14:41:34 +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 266EfTSR2194638; Wed, 6 Jul 2022 10:41:29 -0400 From: Tom Lane To: Ronan Dunklau cc: Hung Nguyen , pgsql-bugs@lists.postgresql.org, "rjuju123@gmail.com" Subject: Re: index cost estimation In-reply-to: <2834175.e9J7NaK4W3@aivenronan> References: <263303.1656769531@sss.pgh.pa.us> <2834175.e9J7NaK4W3@aivenronan> Comments: In-reply-to Ronan Dunklau message dated "Wed, 06 Jul 2022 10:53:52 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2194636.1657118489.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 06 Jul 2022 10:41:29 -0400 Message-ID: <2194637.1657118489@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Ronan Dunklau writes: > Looking into it, it looks like we are not charging a cpu "descent" cost = for = > the entry tree of the gin index, which we do for the btree index. In gen= eral, = > it does not pose a problem since IO costs are far greater than cpu costs= . But = > when the index scan is inside a nestloop, we account for cache effect an= d = > amortize the cost of IO over the number of outer scans, which reduces it= s = > relative importance significantly. In that case, the index scan on the g= in = > index appears much cheaper, as the constant cpu cost is not taken into = > account. = Hm, so it'd seem this probably could happen when comparing *any* non-btree index to a btree index, because I don't think we are particularly careful with CPU cost estimation for any of the other index types. If we do something about this, we probably have to look at all of them. regards, tom lane