From: Andrew Dunstan <andrew@dunslane.net>
To: Peter Geoghegan <pg@bowt.ie>
To: Pavan Deolasee <pavan.deolasee@gmail.com>
Cc: pgsql-committers <pgsql-committers@lists.postgresql.org>
Subject: Re: pgsql: Optimize btree insertions for common case of increasing values
Date: Tue, 10 Apr 2018 18:27:10 -0400
Message-ID: <d505a996-8c8e-4f81-9125-85937e00d2f2@dunslane.net> (raw)
In-Reply-To: <CAH2-Wz=whBsrnmF=CJKBBG=K1euAfmWRg4gx_M=6R+w7Y=d5vw@mail.gmail.com>
References: <E1f0Qx3-0004Z5-KN@gemulon.postgresql.org>
<CAH2-WzmpBA3TVtQCkkupVhxJ7DNsaosnmB9Maiogw0K58BKCKg@mail.gmail.com>
<CABOikdMCoXG3pMU7zUjO2wdVudvZ-5SzD7McedzRbitN_VvuUQ@mail.gmail.com>
<CAH2-Wz=PUWeMajanORdp_cOfe3Z0CVQvzLnKRtN_3OKfMbqPHg@mail.gmail.com>
<CAH2-Wzmh_sxhXYfqhpkD6t+C3K57TRDOMXKdG-NQ6qvjnuW37g@mail.gmail.com>
<CABOikdOm+psQKOB0fRg9YFnVnD+-e3H57yN6hY=HhUKN_TYnbQ@mail.gmail.com>
<CAH2-Wzm_i6TkxppTsT7ZwkGBfaa9fgZrFaW99909-+qYy2BFUA@mail.gmail.com>
<CABOikdNoffgt3XkSKPipawi1QYXxEgs67ZV9OsTVEb6jpQN+iw@mail.gmail.com>
<CAH2-WzkpJd5TP6uRCqa473mzZCNsVk5KjE3xrs-4=FfFiAMHog@mail.gmail.com>
<CAH2-Wzm171z4Q7=waBeTRyZp9-JPYwEYLCWWoTvr9_YzCQeEAQ@mail.gmail.com>
<CABOikdO8jhRarNC60nZLktZYhxt+TK8z_V97+Ny499YQdyAfug@mail.gmail.com>
<CAH2-Wz=whBsrnmF=CJKBBG=K1euAfmWRg4gx_M=6R+w7Y=d5vw@mail.gmail.com>
On 04/10/2018 03:30 PM, Peter Geoghegan wrote:
> On Tue, Apr 10, 2018 at 12:07 PM, Pavan Deolasee
> <pavan.deolasee@gmail.com> wrote:
>> Hmm. I am a bit confused why we want to mention anything about something
>> we're not even considering seriously, let alone any patch or work in that
>> direction. If we at all change everything to use extent based storage, there
>> would be many other things that will break and require changes, no?
> I guess you're right. It's implied by what you already say in the
> nbtree README. No need to do more.
>
>> Apart from that, other changes requested are included in the patch. This
>> also takes care of Heikki's observation regarding UNLOGGED tables on the
>> other thread.
> Cool.
>
> Feedback on this version:
>
>> +without a backend's cached page also being detected as invalidated, but
>> +only when we happen to recycle a page that once again becomes the
>> +rightmost leaf page.
> I suggest wording this as "...but only when we happen to recycle a
> block that once again gets recycled as the rightmost leaf page". (I'm
> correcting my own wording here, I think.)
>
> * No need to start a sentence with "So" here, IMV:
>
>> + * Note the fact that whenever we fail to take the fastpath, we clear
>> + * the cached block. So checking for a valid cached block at this point
>> + * is enough to decide whether we're in a fastpath or not.
> * This should test "if (P_RIGHTMOST(lpageop) && P_ISLEAF(lpageop) &&
> !P_ISROOT(lpageop))", because you don't want to use the optimization
> for internal pages that happen to not be the root -- there is no leaf
> check here:
>
>> + /*
>> + * Cache the block information if we just inserted into the rightmost
>> + * leaf page of the index and it's not the root page. For very small
>> + * index where root is also the leaf, there is no point trying for any
>> + * optimisation.
>> + */
>> + if (P_RIGHTMOST(lpageop) && !P_ISROOT(lpageop))
>> + cachedBlock = BufferGetBlockNumber(buf);
> * I don't think that you should have a #define inline with code like this:
>
>> +#define BTREE_FASTPATH_MIN_LEVEL 2
>> + if (BlockNumberIsValid(cachedBlock) &&
>> + _bt_getrootheight(rel) >= BTREE_FASTPATH_MIN_LEVEL)
>> + RelationSetTargetBlock(rel, cachedBlock);
> I suggest putting this in nbtree.h instead. You can put it just after
> BTREE_NONLEAF_FILLFACTOR, with a comment, in a separate block/section.
>
> Other than that, looks good to me.
>
Committed with light editing. I didn't put the #define in the .h file -
it's only used here and that seemed like unnecessary clutter. I moved it
to the top of the file. I also standardized the spelling of "optimization".
cheers
andrew
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: andrew@dunslane.net, pg@bowt.ie, pavan.deolasee@gmail.com
Subject: Re: pgsql: Optimize btree insertions for common case of increasing values
In-Reply-To: <d505a996-8c8e-4f81-9125-85937e00d2f2@dunslane.net>
References: <E1f0Qx3-0004Z5-KN@gemulon.postgresql.org> <CAH2-WzmpBA3TVtQCkkupVhxJ7DNsaosnmB9Maiogw0K58BKCKg@mail.gmail.com> <CABOikdMCoXG3pMU7zUjO2wdVudvZ-5SzD7McedzRbitN_VvuUQ@mail.gmail.com> <CAH2-Wz=PUWeMajanORdp_cOfe3Z0CVQvzLnKRtN_3OKfMbqPHg@mail.gmail.com> <CAH2-Wzmh_sxhXYfqhpkD6t+C3K57TRDOMXKdG-NQ6qvjnuW37g@mail.gmail.com> <CABOikdOm+psQKOB0fRg9YFnVnD+-e3H57yN6hY=HhUKN_TYnbQ@mail.gmail.com> <CAH2-Wzm_i6TkxppTsT7ZwkGBfaa9fgZrFaW99909-+qYy2BFUA@mail.gmail.com> <CABOikdNoffgt3XkSKPipawi1QYXxEgs67ZV9OsTVEb6jpQN+iw@mail.gmail.com> <CAH2-WzkpJd5TP6uRCqa473mzZCNsVk5KjE3xrs-4=FfFiAMHog@mail.gmail.com> <CAH2-Wzm171z4Q7=waBeTRyZp9-JPYwEYLCWWoTvr9_YzCQeEAQ@mail.gmail.com> <CABOikdO8jhRarNC60nZLktZYhxt+TK8z_V97+Ny499YQdyAfug@mail.gmail.com> <CAH2-Wz=whBsrnmF=CJKBBG=K1euAfmWRg4gx_M=6R+w7Y=d5vw@mail.gmail.com> <d505a996-8c8e-4f81-9125-85937e00d2f2@dunslane.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox