Re: [CFReview] Red-Black Tree

Teodor Sigaev <teodor@sigaev.ru>

From: Teodor Sigaev <teodor@sigaev.ru>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Mark Cave-Ayland <mark.cave-ayland@siriusit.co.uk>, Pgsql Hackers <pgsql-hackers@postgresql.org>
Date: 2010-02-04T15:53:52Z
Lists: pgsql-hackers

Attachments

> I would like to see point #2 of the following email addressed before
> commit.  As things stand, it is not clear (at least to me) whether
> this is a win.

Reimplementation of ginInsertRecordBA reduces difference of HEAD and HEAD+rbtree 
in regular case.
Test suite is taken from http://www.sai.msu.su/~megera/wiki/2009-04-03:

SEQ: SELECT array_to_string(ARRAY(select '' || a || '.' || b from
generate_series(1,50) b), ' ')::tsvector AS i INTO foo FROM
generate_series(1,100000) a;
RND: SELECT array_to_string(ARRAY(select '' || random() from
generate_series(1,50) b), ' ')::tsvector AS i INTO foo FROM
generate_series(1,100000) a;

Times in seconds:
          HEAD      0.9   0.11
SEQ       130      113    111
RND        11.4     12.6   11.5

The ides was to change order of insertion - now insertion order decreases number 
of rebalancing.

Oleg's test (http://www.sai.msu.su/~megera/wiki/rbtree_test) are made with v0.10 
which is differ from 0.11 only by comments around ginInsertRecordBA()
-- 
Teodor Sigaev                                   E-mail: teodor@sigaev.ru
                                                    WWW: http://www.sigaev.ru/