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 1onKcE-00031i-Ta for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Oct 2022 14:09:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1onKcD-0004y6-M6 for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Oct 2022 14:09:13 +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 1onKcD-0004xx-CD for pgsql-hackers@lists.postgresql.org; Tue, 25 Oct 2022 14:09:13 +0000 Received: from mail-qv1-xf2a.google.com ([2607:f8b0:4864:20::f2a]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1onKcB-0001aX-1A for pgsql-hackers@lists.postgresql.org; Tue, 25 Oct 2022 14:09:12 +0000 Received: by mail-qv1-xf2a.google.com with SMTP id o8so8637869qvw.5 for ; Tue, 25 Oct 2022 07:09:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=KXknPG87PK4J8Rva39rUx+kcptVZ1CiZyv8L5b+AWlE=; b=GQe4x+sJqZ7v7rm1JNUMMdcmDtutffeMmVLuiobVfUBAs3FgU4j34q/+HvCyVXaybF N3BeaRujfGCUAaclmY/TSfFA7WGCGvGk8b++IIcvVlHq+9/zu+zcY7ytu8GhtY6foiKv wVLw45/rkx2PW4v7ebkJYkO0L46p2UMTGVH+/9biWiy58nq2dkIcfgSM8Y/oeRE31Q4W +UvIImrazj+cGfgEwuj8FNKnHaSyRjgZTDRuy982w94noYZ4NEa4FJppSLl+cM1OjyFv 6GZGIe1ooavfwtZT8y4gXKhSaRUQvKfgwbglyOHGe2KgL2ju/JWzEy8ij/2qMgh35acH NE1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=KXknPG87PK4J8Rva39rUx+kcptVZ1CiZyv8L5b+AWlE=; b=6szbHrblKHcoT5Av/2x8zROkarUUfrt/WP4HosMaewgsFH1CUOtvwD9eZRELRormej id9t0gShM+LfKN4YgWPjar05LH48yID2/BoSFw49n5ecA8tT2IK4au/6Qdx+Ij9kWso4 tEAY1Fv2N6s6SPVSRsQQh9z/5foNWg7OEn4dUN04hMfKGPntUWqtbPkv16Sw7Xf30UFN 3kDHS+ypflPPSHEuy3Ow48GTC1vkyWa2unpvwTNiP4W9PNtryIueL77plwrSic6IiL19 fhlp2xZ37hA35LV2iIgrMFWe9eUs8zijJns1Fd94X9srDPIIdROOeonSpVSJoF0B2qEb 2+Qw== X-Gm-Message-State: ACrzQf27q4SlZ3/1Un547Oa/UMltQTMPaOL51Xj/7OdQx8x0VC2k/dP7 Vi+4gTGRHrDWmZrPHnI2+J5BBYKichBxHpZzn0k= X-Google-Smtp-Source: AMsMyM4+b0nrGg+rQecFL9wBt1mOmC3av3jkUSqrno1pCm/TI8PdFRduF7K2TTcrY4kUnmMJgO3lA+OLIrdJQk3pp7s= X-Received: by 2002:a05:6214:2389:b0:4bb:59ec:c5b1 with SMTP id fw9-20020a056214238900b004bb59ecc5b1mr17079282qvb.48.1666706949346; Tue, 25 Oct 2022 07:09:09 -0700 (PDT) MIME-Version: 1.0 References: <3188617.44csPzL39Z@aivenronan> <4768224.31r3eYUQgx@aivenronan> <12071145.O9o76ZdvQC@aivenronan> In-Reply-To: <12071145.O9o76ZdvQC@aivenronan> From: Alexander Korotkov Date: Tue, 25 Oct 2022 17:08:58 +0300 Message-ID: Subject: Re: Fix gin index cost estimation To: Ronan Dunklau Cc: Michael Paquier , Tom Lane , pgsql-hackers@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000a91aa605ebdc7342" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000a91aa605ebdc7342 Content-Type: text/plain; charset="UTF-8" Hi, Ronan! On Wed, Oct 12, 2022 at 10:15 AM Ronan Dunklau wrote: > > > You're right, I was too eager to try to raise the CPU cost proportionnally > to > > > the number of array scans (scalararrayop). I'd really like to understand > where > > > this equation comes from though... > > > > So, what's the latest update here? > > Thanks Michael for reviving this thread. > > Before proceeding any further with this, I'd like to understand where we > stand. Tom argued my way of charging cost per entry pages visited boils down > to charging per tuple, which I expressed disagreement with. > > If we can come to a consensus whether that's a bogus way of thinking about it > I'll proceed with what we agree on. I briefly read the thread. I think this line is copy-paste from other index access methods and trying to estimate the whole index scan CPU cost by bypassing all the details. *indexTotalCost += (numTuples * *indexSelectivity) * (cpu_index_tuple_cost + qual_op_cost); I think Tom's point was that it's wrong to add a separate entry-tree CPU cost estimation to another estimation, which tries (very inadequately) to estimate the whole scan cost. Instead, I propose writing better estimations for both entry-tree CPU cost and data-trees CPU cost and replacing existing CPU estimation altogether. ------ Regards, Alexander Korotkov --000000000000a91aa605ebdc7342 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi, Ronan!

On Wed, Oct 12, 2022 at 10:15 AM Ronan D= unklau <ronan.dunklau@aiven.io= > wrote:
> > > You're right, I was too eager to try = to raise the CPU cost proportionnally
> to
> > > the numb= er of array scans (scalararrayop). I'd really like to understand
>= ; where
> > > this equation comes from though...
> >> > So, what's the latest update here?
>
> Thanks M= ichael for reviving this thread.
>
> Before proceeding any furt= her with this, I'd like to understand where we
> stand. Tom argue= d my way of charging cost per entry pages visited boils down
> to cha= rging per tuple, which I expressed disagreement with.
>
> If we= can come to a consensus whether that's a bogus way of thinking about i= t
> I'll proceed with what we agree on.

I briefly read the= thread. I think this line is copy-paste from other index access methods an= d trying to estimate the whole index scan CPU cost by bypassing all the det= ails.

*indexTotalCost +=3D (numTuples * *in= dexSelectivity) * (cpu_index_tuple_cost + qual_op_cost);

I th= ink Tom's point was that it's wrong to add a separate entry-tree CP= U cost estimation to another estimation, which tries (very inadequately) to= estimate the whole scan cost. Instead, I propose writing better estimation= s for both entry-tree CPU cost and data-trees CPU cost and replacing existi= ng CPU estimation altogether.

------
Regards,
Alexander Korot= kov
--000000000000a91aa605ebdc7342--