On 2019-02-01 16:04:58 -0500, James Coleman wrote: > On Thu, Jan 31, 2019 at 1:32 AM Kyotaro HORIGUCHI > <horiguchi.kyot...@lab.ntt.co.jp> wrote: > > 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? > > I'd like to offer a counterpoint: in cases where this a huge win we > definitely do want this to affect cost estimation, because if it's > purely an executor optimization the index scan path may not be chosen > even when skip scanning would be a dramatic improvement.
+many. Greetings, Andres Freund