Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gpeQg-0005OB-FH for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Feb 2019 19:24:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gpeQe-0007e3-OZ for pgsql-hackers@arkaria.postgresql.org; Fri, 01 Feb 2019 19:24:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gpeQe-0007Xu-D5 for pgsql-hackers@lists.postgresql.org; Fri, 01 Feb 2019 19:24:44 +0000 Received: from mail-qt1-f195.google.com ([209.85.160.195]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gpeQb-0005JO-Hs for pgsql-hackers@postgresql.org; Fri, 01 Feb 2019 19:24:43 +0000 Received: by mail-qt1-f195.google.com with SMTP id l11so8937206qtp.0 for ; Fri, 01 Feb 2019 11:24:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:cc:references:from :organization:message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=hxh76Fejg5TE+gX0HL+aSqtBCDL7fWLERAQOIam8X1s=; b=B5+0zum1yucFw5JeY1Us1twJLnxlBgyWPfvdAXXCH1i+CHi1DLFNuElLDUVqtnJ/fZ bDAKbJBEqUHBL81Kuo6T4MZzqygeGcQFwPpGwWjRdQ4QRxqUtaGUUyTa8hTrwH3jvqst 4qqD5f9yuHcbrMyXARFvgF2cLbmzSYE4eO+MMYU1lrHLyog8y9tHDB82ZtakrpomrJw1 eUuwcelL5kjPYCRsPqDH54hqJ/DlVtt5ZYU2hIMXFh+uqb15ZyAUq3+xXsRmAKTZG/Cv 95vLEoiJj9Og7wnm98xssVbM+Ro40sHW9LUiF13OsVqBkP8u0T+owEa1tGjic/rKxFtX kjZA== X-Gm-Message-State: AJcUukeju2PC3GoAFd0rxSWo+ElCol86iY7YNoCbk3BIPOZTkYbJQzEl AQqQnmwyoEJGG2r8z+W/XflLIA== X-Google-Smtp-Source: ALg8bN6dg2XB2RSjaiigMSXYmU+62wnSVf5K6EDccBoBuB3S2SmaNAl8H8kOX/YyoB5jjfxx0PIHOg== X-Received: by 2002:ad4:4084:: with SMTP id l4mr37970653qvp.165.1549049080932; Fri, 01 Feb 2019 11:24:40 -0800 (PST) Received: from localhost.localdomain (c-24-61-8-151.hsd1.ma.comcast.net. [24.61.8.151]) by smtp.gmail.com with ESMTPSA id h31sm11268814qtk.5.2019.02.01.11.24.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 11:24:39 -0800 (PST) Reply-To: jesper.pedersen@redhat.com Subject: Re: Index Skip Scan To: Kyotaro HORIGUCHI , 9erthalion6@gmail.com Cc: a.kuzmenkov@postgrespro.ru, pg@bowt.ie, thomas.munro@enterprisedb.com, bhushan.uparkar@gmail.com, pgsql-hackers@postgresql.org, a.korotkov@postgrespro.ru, jtc331@gmail.com References: <20190131.153153.83078698.horiguchi.kyotaro@lab.ntt.co.jp> From: Jesper Pedersen Organization: Red Hat Message-ID: Date: Fri, 1 Feb 2019 14:24:38 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190131.153153.83078698.horiguchi.kyotaro@lab.ntt.co.jp> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 1/31/19 1:31 AM, Kyotaro HORIGUCHI wrote: > At Wed, 30 Jan 2019 18:19:05 +0100, Dmitry Dolgov <9erthalion6@gmail.com> wrote in >> A bit of adjustment after nodes/relation -> nodes/pathnodes. > > I had a look on this. > > The name "index skip scan" is a different feature from the > feature with the name on other prodcuts, which means "index scan > with postfix key (of mainly of multi column key) that scans > ignoring the prefixing part" As Thomas suggested I'd suggest that > we call it "index hop scan". (I can accept Hopscotch, either:p) > > Also as mentioned upthread by Peter Geoghegan, this could easly > give worse plan by underestimation. So I also suggest that this > has dynamic fallback function. In such perspective it is not > suitable for AM API level feature. > > If all leaf pages are on the buffer and the average hopping > distance is less than (expectedly) 4 pages (the average height of > the tree), the skip scan will lose. If almost all leaf pages are > staying on disk, we could win only by 2-pages step (skipping over > one page). > > ===== > As I'm writing the above, I came to think that it's better > implement this as an pure executor optimization. > > Specifically, let _bt_steppage count the ratio of skipped pages > so far then if the ratio exceeds some threshold (maybe around > 3/4) it gets into hopscotching mode, where it uses index scan to > find the next page (rather than traversing). As mentioned above, > I think using skip scan to go beyond the next page is a good > bet. If the success ration of skip scans goes below some > threshold (I'm not sure for now), we should fall back to > traversing. > > Any opinions? > > ==== > > Some comments on the patch below. > > + skip scan approach, which is based on the idea of > + > + Loose index scan. Rather than scanning all equal values of a key, > + as soon as a new value is found, it will search for a larger value on the > > I'm not sure it is a good thing to put a pointer to rather > unstable source in the documentation. > > > This adds a new AM method but it seems avaiable only for ordered > indexes, specifically btree. And it seems that the feature can be > implemented in btgettuple since btskip apparently does the same > thing. (I agree to Robert in the point in [1]). > > [1] https://www.postgresql.org/message-id/CA%2BTgmobb3uN0xDqTRu7f7WdjGRAXpSFxeAQnvNr%3DOK5_kC_SSg%40mail.gmail.com > > > Related to the above, it seems better that the path generation of > skip scan is a part of index scan. Whether skip scan or not is a > matter of index scan itself. > Thanks for your valuable feedback ! And, calling it "Loose index scan" or something else is better. Dmitry and I will look at this and take it into account for the next version. For now, I have switched the CF entry to WoA. Thanks again ! Best regards, Jesper