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 1jtwRB-0005Pn-9s for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Jul 2020 17:03:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jtwRA-0005i3-3B for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Jul 2020 17:03:48 +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 1jtwR9-0005fZ-SC for pgsql-hackers@lists.postgresql.org; Fri, 10 Jul 2020 17:03:47 +0000 Received: from smtp03.optiver.com ([195.246.114.70]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jtwR7-0004kl-Bt for pgsql-hackers@postgresql.org; Fri, 10 Jul 2020 17:03:47 +0000 Received: from pps.filterd (smtp03.optiver.com [127.0.0.1]) by smtp03.optiver.com (8.16.0.27/8.16.0.27) with SMTP id 06AH2EgF001645; Fri, 10 Jul 2020 19:03:38 +0200 Received: from opammb0561.comp.optiver.com (opammb0561.comp.optiver.com [10.131.160.1]) by smtp03.optiver.com with ESMTP id 325k34hdh2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 10 Jul 2020 19:03:38 +0200 Received: from opammb0561.comp.optiver.com (10.131.160.1) by opammb0561.comp.optiver.com (10.131.160.1) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 10 Jul 2020 19:03:38 +0200 Received: from opammb0561.comp.optiver.com ([fe80::78c7:ae96:9b5c:c00]) by opammb0561.comp.optiver.com ([fe80::78c7:ae96:9b5c:c00%17]) with mapi id 15.00.1497.006; Fri, 10 Jul 2020 19:03:38 +0200 From: Floris Van Nee To: Dmitry Dolgov <9erthalion6@gmail.com>, Andy Fan CC: PostgreSQL-development , Jesper Pedersen , David Rowley , "Kyotaro Horiguchi" , Peter Geoghegan , "Thomas Munro" , Tomas Vondra , Dilip Kumar Thread-Topic: Index Skip Scan (new UniqueKeys) [External] Thread-Index: AQHWPkejvFmf8VE85UaktavhwXWuBqjS8neAgByLE4CAEbyf4A== Date: Fri, 10 Jul 2020 17:03:37 +0000 Message-ID: References: <20200609102247.jdlatmfyeecg52fi@localhost> <20200629120709.52w2zi36mtzyliv2@localhost> In-Reply-To: <20200629120709.52w2zi36mtzyliv2@localhost> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.131.160.182] x-tm-as-product-ver: SMEX-14.0.0.1158-8.6.1012-25534.001 x-tm-as-result: No-10--6.031700-8.000000 x-tmase-matchedrid: oTBA/+sdKabuo96mfIBuopzEHTUOuMX33dCmvEa6IiGoLZarzrrPmcuo oB2sakIfLbk2T1OrtjuK8x5AnGBorl5rYINUsB8jbsgxiL78FtKGm/9Tv2/OgfZ5Vxjb3pQXP+n ZnJuCIKAIFmTVShW9at/H7HccMVo/0OpgznwXlEED2WXLXdz+ATADw195g8UGUJoXCtuJyr6ONW IsOr2UIMtvYw88b+QeAkW8RTSnRrZ7rjItHwarhW9ck5v+UY9LcpieE6yH5w+bKItl61J/yZkw8 KdMzN86KrauXd3MZDVCiXj8cRDfr/9af4NrKBAU2IeaiBXi5RPuMDMSkQygd6IEhBowxkeGwL6S xPpr1/I= x-tm-as-user-approved-sender: Yes x-tm-as-user-blocked-sender: No x-tmase-result: 10--6.031700-8.000000 x-tmase-version: SMEX-14.0.0.1158-8.6.1012-25534.001 x-tm-snts-smtp: FE15E03A815A5774A1495A88A9DDB76ECA2D94C46F32DCE1C41DB06E5DAB74A82000:8 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: RE: Index Skip Scan (new UniqueKeys) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-10_13:2020-07-10,2020-07-10 signatures=0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi Dmitry, Also took another look at the patch now, and found a case of incorrect data= . It looks related to the new way of creating the paths, as I can't recall = seeing this in earlier versions. create table t1 as select a,b,b%5 as c, random() as d from generate_series(= 1, 10) a, generate_series(1,100) b; create index on t1 (a,b,c); postgres=3D# explain select distinct on (a) * from t1 order by a,b desc,c; QUERY PLAN = =20 ---------------------------------------------------------------------------= ---- Sort (cost=3D2.92..2.94 rows=3D10 width=3D20) Sort Key: a, b DESC, c -> Index Scan using t1_a_b_c_idx on t1 (cost=3D0.28..2.75 rows=3D10 wi= dth=3D20) Skip scan: true (4 rows) With the 'order by a, b desc, c' we expect the value of column 'b' to alway= s be 100. With index_skipscan enabled, it always gives 1 though. It's not c= orrect that the planner chooses a skip scan followed by sort in this case. -Floris