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 1ksfiP-0004Gw-Ce for pgsql-general@arkaria.postgresql.org; Fri, 25 Dec 2020 05:32:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ksfiM-0001PV-P8 for pgsql-general@arkaria.postgresql.org; Fri, 25 Dec 2020 05:32:34 +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 1ksfiM-0001OZ-6m for pgsql-general@lists.postgresql.org; Fri, 25 Dec 2020 05:32:34 +0000 Received: from sonic310-15.consmr.mail.bf2.yahoo.com ([74.6.135.125]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ksfiF-00073J-OR for pgsql-general@lists.postgresql.org; Fri, 25 Dec 2020 05:32:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1608874344; bh=hBTSiOcQiHL/0zdsHYZZsFXJ5mn/XXzVKVVsLUolxUA=; h=Date:From:To:Subject:References:From:Subject; b=rpJvZBJTie7tDST5C1EbXRt7YVqhajNeSbH5VBBGWFtbrVmjVDKd6HVCv6VgR7gKHe4pdo88J+UxsKf2jmWk+w9V/BWYOItzmgmrkd83MbNHHPB7MI1woib7Ucv7IGyc0x09qWGmxatGEkh2v0UZz1T/IRUg6kbbUlBGBLSwPr3B3Qq8ae7l8dwYcHw9WROcwkn8EablcTHr7BLaYFeW9YL2oQK2o0RnmqbbE/+kOLA5limhhB+xizxtwPtt1A4wrLTtkFVZTC2htg01qLWPXQ7wsuQ64vETf3acoYUQeRFvibtgEV+T35rIaWSfJzVS9xlNoF75s1v38IBh4Dcagg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1608874344; bh=hZkq0knHHLhzhHpGkKabaQZyn5UgVGEvDQyuA2nc35d=; h=Date:From:To:Subject:From:Subject; b=kGWGUDf65+x4R99xg/h23eRFllzzC9Rp3MEiwBy3K2VJkbOJtoaIlzZi+gOUhEBWXj6blf0bJaQYWWaXM4Ab0CgaTf71q2TX37biLGxXTTXjxakGmKonBhgvnwuhS3sxmg9LembT1DnCiGdbpKMAVek603xPeIEZsXaLyFlFmz2/4SjrI/bEWf3gcUm6QF+8VrQscK9jRWs2h5Bzjc2CFteqYSWEW1TX1fEPuclKKZkZhvdEwxz6bzhdx6Y34XlIjoWRs7UmcwIsTandyfuBmUH7VqjL8376p8i1yV0EoEoZBm0LWKmkkrNDW4THv6AzpPUatWvoML1LZQgAiKKWDQ== X-YMail-OSG: xb4b7YkVM1me4N1Un5dG9.cG6LE9fnXI1_cWbyY652R54XSh98NuTyMSvJwIB84 dpXPhhM21vWyMome1BWvQPjvngpUDV9xg179u0bxYxzHWJN8YPDy7EWRaEr2K9UcbEQtrLV2uy3X DBlvjMhxasSBEJXJ0dKpkhZTOfu5tJ7SBHFYwIAwtOuK0sCZCNWmncbbcc1QbxSje8Cx5i4X48Mi pSdH.lFw28ePsfQsub5b_sUpccH_IF74bz3OIPzRKuNozhdKNJyt5NR16IHWhJqwgZRGyKWjs8O9 ZcT1P30kIz1PXZ3rerc4cPUZfXfiOghf5ld04qXR2VeEwrMdIswg4EAZ6KHXMO11w6HOElHHyrt8 Nhl0wb45VQ1XHJqeTJuv0smqy5jkCMdCSby8b.C3hQZFjo_ZSZ6KLEbLW0AXOSfvZysXUnO2iIVA MrSb.O9yxjdxWwa0oEZmOuFnwmszlobgctozt3wCia15tWfmlAEALVSMg2eRpI2FmfzkYvRI2HU. OQVaCFXkfZ.JmEPSOGSNrkrkF346N8O1Ndt6y.jJq1uQu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SFEC2Ma_vQoNm1vfVG_ IP7MLYng1crmQc.UxkAGcS.xf9Pmqt6ITO9kHPB1XMKCY1YhXQM6FWUCF2yKZiYQbSNi5PrInaci aR7SUbFJVYen0iKBjTRofwiYbhGdh2oX8Zgd.aYFV9L95Zl61Xw6JWYD_9u69L2oWkjOW4.Jiv0S q1S8h_ECXYWHu4.yC_4aizdf082QbcBOIoCRm5Jq57BjpXHALa_JkgHC0._teLLH590_D31nAS00 VnvVvGYa94bY6el0zUjlpB_0RFl83HH_sECLIPCoN81zKASoRixcNT3QnDY_OyiO.skKaBBVK.pj 1VEvWdgxUCBLmkMzGSv_WicjOmjgZ6kVMgryxI95UPiWWEY.sapldvmTFcPwqJ6RTBcV_yxdeqJ3 B71Ql4HF7PaYISDcctCVU57q399niUOSedL.kLw1knhtNriroVgtoZMZz3f9P_J8yAmDO0L8bAOz zKKxFsZlp3oe0hlKHqkvSm..3jv4Mpzn4KWQemja7DZE8XtiOTnl0BCe69WyeAmy3iP3NQjzdXXi a6NLMhnS6iCyVK4WF0UthexyDfqWYKaGzGgDZPE0oYwDFHQWazQWpI1DW5hYKhnBPKGtRdcH3n8k tFhm3C1JgfbGiAnE4xAXeI0qtp_7PRT0MdmTCMh9j9eJsv1uQ9eLGxLTgOf0.fQGQZ6wfxO3JHNU dlQj3YZUPAN8HtgDGVvoBAveV.n9rO2k.VDpuLQuuGE5EF.n1a8GGlYkoVkJPbC4vZxLd2DLFnkw qXCO4eM8nurSs44wKksDw2gJSr71dlgzeWIz8SZ40S.PGqIc3f3by04vOh1XM2kiq8o6tGYxh3b3 mGBEiy068_LxEdSXu3rAKTu2lLBKpC7lseSgAZZeGBTF7p6o8PrllwA-- Received: from sonic.gate.mail.ne1.yahoo.com by sonic310.consmr.mail.bf2.yahoo.com with HTTP; Fri, 25 Dec 2020 05:32:24 +0000 Date: Fri, 25 Dec 2020 05:32:16 +0000 (UTC) From: Shantanu Shekhar To: "pgsql-general@lists.postgresql.org" Message-ID: <1258055935.2714481.1608874336314@mail.yahoo.com> Subject: Stats for indexes on expressions MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_2714480_1230299134.1608874336313" References: <1258055935.2714481.1608874336314.ref@mail.yahoo.com> X-Mailer: WebService/1.1.17278 YMailNorrin Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Content-Length: 2743 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_2714480_1230299134.1608874336313 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hello, I am trying to understand how the cost for a query involving indexes on exp= ressions is calculated. How is the statistics on the expression maintained?= For example Postgres documentation on 'Indexes on Expressions' mentions th= e following example: CREATE INDEX people_names ON people ((first_name || ' ' || last_name));SELE= CT * FROM people WHERE (first_name || ' ' || last_name) =3D 'John Smith'; The index is created on an expression involving first name and last name. M= y confusion is basically around: (1) When using this index how will the query planner get the stats on this = expression?=C2=A0(2) Whenever an index on an expression is defined like thi= s, should we rebuild the stats?=C2=A0 Thanks, Shantanu ------=_Part_2714480_1230299134.1608874336313 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hello,

I am trying to unde= rstand how the cost for a query involving indexes on expressions is calcula= ted. How is the statistics on the expression maintained? For example Postgr= es documentation on 'Indexes on Expressions' mentions the following example= :

CREATE INDEX people_names ON people ((first_n= ame || ' ' || last_name));
SELECT * FROM people WHERE (first_name= || ' ' || last_name) =3D 'John Smith';

The index is created on an expression involving fi= rst name and last name. My confusion is basically around:

(1) When using this index how will the query planner get the stats on this= expression? 
(2) Whenever= an index on an expression is defined like this, should we rebuild the stat= s? 

Thanks,

Shantanu



------=_Part_2714480_1230299134.1608874336313--