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 1jZZZc-0004lp-A8 for pgsql-hackers@arkaria.postgresql.org; Fri, 15 May 2020 12:36:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jZZZb-0006wO-3a for pgsql-hackers@arkaria.postgresql.org; Fri, 15 May 2020 12:36:19 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <9erthalion6@gmail.com>) id 1jZZZa-0006vf-Qp for pgsql-hackers@lists.postgresql.org; Fri, 15 May 2020 12:36:18 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from <9erthalion6@gmail.com>) id 1jZZZU-0004fi-IG for pgsql-hackers@postgresql.org; Fri, 15 May 2020 12:36:17 +0000 Received: by mail-wm1-x344.google.com with SMTP id u16so2475602wmc.5 for ; Fri, 15 May 2020 05:36:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=VH/tFUFM0pMkQzZo1GXRfAPGIWqh6HOBEJDUEcB5m1g=; b=jy4Ye6CvF9V1dt/TvBt6bJ52NwtAFbdizG47dd7j7NIrqW/25ACxwYMDW46v+8xa+M qZR1bVa9H6um7eTYivEzoXmZ8eoLiqjjUBjYgVxVX639V9yqDxrZw1MmHODcUtFfBDo9 EF7LNfxr3rqHp9lvwrkHjzKqf6UrimXc+NftH/B4vWwLunKLIVSeXCtQxR6EVyr4QmvP 92wGe4WkkivZbJNl3aVSxTH93GdPLD6J5ZT98wrsIwmDS58FH39lnFynukPV1Q3o8H+D QH0yO04j2z7KLITCYzjdGjIywrAeAiBbOleAXjrZ8ZVD8bWGODU9Mmu37aVOegsblAw5 eXVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=VH/tFUFM0pMkQzZo1GXRfAPGIWqh6HOBEJDUEcB5m1g=; b=Ix8f81fW5NZ5Wii1UXgAzQzA2Qp5/VYAJPDKAkb30X2wBaWdujrF7SIBj+HUOmPIWg d0Uycmi1pby+/l5FlJfacpYo1+TysXgzBwJHcUz4el29kH7tq9s91+eNgKDI9aa8oLLZ zp+ZEZtiPMUWgaDB7pTBUMxpW98VulGxBLHbPRMMHfzV6nAhkuofrui5qkhZ2x+h6d8x retI5Em3Dw1cbkTUQCL1GwI9+qHqRrv2n4ZDju0nOYgIUX1/Ci1ep3HI/gzp0mAw+BC6 vJkHFDJbSbO4dm7/SnJrxR27DV97L8TE55AzraKwuAJeejh50pEQ6TlHabIOvEO2IN3g l8Ug== X-Gm-Message-State: AOAM531bbsCfwZXEUArVfFhjQ/kT//GG3g2Y2xOQJQ4Gezt+FVSoBSbb h6yuqgobh9mpCH6MUg8DQlw= X-Google-Smtp-Source: ABdhPJxnZznPS/zuPLtfoLEgp93M42YWGGEIwU1fxrjpbdAoU2tZhfdeobSI9Lczum+tzGEPs5ewCg== X-Received: by 2002:a1c:f606:: with SMTP id w6mr3771523wmc.59.1589546170664; Fri, 15 May 2020 05:36:10 -0700 (PDT) Received: from localhost (dslb-094-222-004-201.094.222.pools.vodafone-ip.de. [94.222.4.201]) by smtp.gmail.com with ESMTPSA id a14sm3299311wme.21.2020.05.15.05.36.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 May 2020 05:36:09 -0700 (PDT) Date: Fri, 15 May 2020 14:38:02 +0200 From: Dmitry Dolgov <9erthalion6@gmail.com> To: Dilip Kumar Cc: Floris Van Nee , David Rowley , Kyotaro Horiguchi , Tomas Vondra , Peter Geoghegan , Jesper Pedersen , Alvaro Herrera , Thomas Munro , James Coleman , Rafia Sabih , Jeff Janes , "bhushan.uparkar@gmail.com" , PostgreSQL-development , Alexander Korotkov Subject: Re: Index Skip Scan Message-ID: <20200515123802.xhppukhcqemmnbqe@localhost> References: <80ef5f0744f542b18e508fb589a6425a@opammb0562.comp.optiver.com> <20200406163941.rh3okji2rhbnptyt@localhost> <8abe43ac82714c2f9044fb8bac0ebfd0@opammb0562.comp.optiver.com> <20200407194220.edf4nbi7l4cpxk4v@localhost> <20200510174935.teqyazdw6jj6vh47@localhost> <20200511112655.ijz2sjltzdpif3cn@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On Wed, May 13, 2020 at 02:37:21PM +0530, Dilip Kumar wrote: > > + if (_bt_scankey_within_page(scan, so->skipScanKey, so->currPos.buf, dir)) > + { > > Here we expect whether the "next" unique key can be found on this page > or not, but we are using the function which suggested whether the > "current" key can be found on this page or not. I think in boundary > cases where the high key is equal to the current key, this function > will return true (which is expected from this function), and based on > that we will simply scan the current page and IMHO that cost could be > avoided no? Yes, looks like you're right, there is indeed an unecessary extra scan happening. To avoid that we can see the key->nextkey and adjust higher boundary correspondingly. Will also add this into the next rebased patch, thanks!