I think one of the most serious issues with BRIN indexes is how they
don't get updated automatically as the table is filled. This patch
attempts to improve on that. During brininsert() time, we check whether
we're inserting the first item on the first page in a range. If we are,
request autovacuum to do a summarization run on that table. This is
dependent on a new reloption for BRIN called "autosummarize", default
off.
The way the request works is that autovacuum maintains a DSA which can
be filled by backends with "work items". Currently, work items can
specify a BRIN summarization of some specific index; in the future we
could use this framework to request other kinds of things that do not
fit in the "dead tuples / recently inserted tuples" logic that autovac
currently uses to decide to vacuum/analyze tables.
However, it seems I have not quite gotten the hang of DSA just yet,
because after a couple of iterations, crashes occur. I think the reason
has to do with either a resource owner clearing the DSA at an unwelcome
time, or perhaps there's a mistake in my handling of DSA "relative
pointers" stuff.
This patch was initially written by Simon Riggs, who envisioned that
brininsert itself would invoke the summarization. However, this doesn't
work because summarization requires having ShareUpdateExclusive lock,
which brininsert doesn't have. So I modified things to instead use the
DSA stuff. (He also set things up so that brininsert would only
summarize the just-filled range, but I didn't preserve that idea in the
autovacuum-based implementation; some changed lines there can probably
be removed.)
--
Álvaro Herrera PostgreSQL Expert, https://www.2ndQuadrant.com/
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers