Re: Sequential vs. random values - number of pages in B-tree - Mailing list pgsql-general

From Francisco Olarte
Subject Re: Sequential vs. random values - number of pages in B-tree
Date
Msg-id CA+bJJbyDsFRG33NNUExoHpVcXmk9iw94KWF8NXqC7nYLSwFvWA@mail.gmail.com
Whole thread Raw
In response to Re: Sequential vs. random values - number of pages in B-tree  (Rob Sargent <robjsargent@gmail.com>)
List pgsql-general
Hi Rob:

On Tue, Aug 23, 2016 at 4:52 PM, Rob Sargent <robjsargent@gmail.com> wrote:
> By 'this' I was referring to the optimizations mentioned, and am wondering
> if this holds true under user load.

For that you'll have to refer to the source, or ask someone more
versed in pg source arcanes.

> Much magic can happen in a custom data
> load, but do these optimization apply to an application loading single (or
> perhaps several) records per transaction.  Does one, in that scenario, not
> suffer any consequence for continuously loading one side of the tree (the
> rightmost node?).

Not that much magic is neccesary. The time I did it I just needed to
detect on every insertion whether I was at the rightmost position (
made easier because I had minimum/maximum keys cached in the tree
object header ), and have a special routine for inserting a new last
node ( put in last page, whose pointer I had, grabbing a new one of
needed, whose pointer will be appended at the tail of the parent,
etc.., it was just a pruned down version of the general insert
routine, but made insertions run easily 20 times faster by avoiding
nearly every check knowing I was on the right edge ). I do not know if
pg inserts several items at a time in bulk loading, but I doubt it.
Normally every btree indexing library has some optimization for this
cases, as they are common, just like every real sort routine has some
optimization for presorted input.

Francisco Olarte.


pgsql-general by date:

Previous
From: Rob Sargent
Date:
Subject: Re: Sequential vs. random values - number of pages in B-tree
Next
From: Alexander Farber
Date:
Subject: Forward declaration of table