postgresql/src/backend/utils
Robert Haas 6d46f4783e Improve hash index bucket split behavior.
Previously, the right to split a bucket was represented by a
heavyweight lock on the page number of the primary bucket page.
Unfortunately, this meant that every scan needed to take a heavyweight
lock on that bucket also, which was bad for concurrency.  Instead, use
a cleanup lock on the primary bucket page to indicate the right to
begin a split, so that scans only need to retain a pin on that page,
which is they would have to acquire anyway, and which is also much
cheaper.

In addition to reducing the locking cost, this also avoids locking out
scans and inserts for the entire lifetime of the split: while the new
bucket is being populated with copies of the appropriate tuples from
the old bucket, scans and inserts can happen in parallel.  There are
minor concurrency improvements for vacuum operations as well, though
the situation there is still far from ideal.

This patch also removes the unworldly assumption that a split will
never be interrupted.  With the new code, a split is done in a series
of small steps and the system can pick up where it left off if it is
interrupted prior to completion.  While this patch does not itself add
write-ahead logging for hash indexes, it is clearly a necessary first
step, since one of the things that could interrupt a split is the
removal of electrical power from the machine performing it.

Amit Kapila.  I wrote the original design on which this patch is
based, and did a good bit of work on the comments and README through
multiple rounds of review, but all of the code is Amit's.  Also
reviewed by Jesper Pedersen, Jeff Janes, and others.

Discussion: http://postgr.es/m/CAA4eK1LfzcZYxLoXS874Ad0+S-ZM60U9bwcyiUZx9mHZ-KCWhw@mail.gmail.com
2016-11-30 15:39:21 -05:00
..
adt Improve eqjoinsel_semi's behavior for small inner relations with no stats. 2016-11-29 18:00:56 -05:00
cache Simplify code by getting rid of SPI_push, SPI_pop, SPI_restore_connection. 2016-11-08 17:39:57 -05:00
error Add a nonlocalized version of the severity field to client error messages. 2016-08-26 16:20:17 -04:00
fmgr Simplify code by getting rid of SPI_push, SPI_pop, SPI_restore_connection. 2016-11-08 17:39:57 -05:00
hash Add macros to make AllocSetContextCreate() calls simpler and safer. 2016-08-27 17:50:38 -04:00
init Add macros to make AllocSetContextCreate() calls simpler and safer. 2016-08-27 17:50:38 -04:00
mb Make all unicode perl scripts to use strict, rearrange logic for clarity. 2016-11-30 18:06:34 +02:00
misc Bring some clarity to the defaults for the xxx_flush_after parameters. 2016-11-25 18:36:10 -05:00
mmgr Make AllocSetContextCreate throw an error for bad context-size parameters. 2016-08-29 09:29:26 -04:00
resowner Improve hash index bucket split behavior. 2016-11-30 15:39:21 -05:00
sort Limit the number of number of tapes used for a sort to 501. 2016-11-15 10:30:33 -05:00
time Account for catalog snapshot in PGXACT->xmin updates. 2016-11-15 15:55:35 -05:00
.gitignore Avoid maintaining three separate copies of the error codes list. 2011-02-03 22:32:49 -05:00
Gen_dummy_probes.pl Finish pgindent run for 9.6: Perl files. 2016-06-12 04:19:56 -04:00
Gen_dummy_probes.sed Update copyright for 2016 2016-01-02 13:33:40 -05:00
Gen_fmgrtab.pl Update copyright for 2016 2016-01-02 13:33:40 -05:00
Makefile Make handling of errcodes.h more consistent with other generated headers. 2011-02-04 09:29:10 -05:00
errcodes.txt Relax transactional restrictions on ALTER TYPE ... ADD VALUE. 2016-09-05 12:59:55 -04:00
generate-errcodes.pl Update copyright for 2016 2016-01-02 13:33:40 -05:00
probes.d Refer to OS X as "macOS", except for the port name which is still "darwin". 2016-09-25 15:40:57 -04:00