pgsql: Remove unnecessary relcache flushes after changing btree metapag - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Remove unnecessary relcache flushes after changing btree metapag
Date
Msg-id E1WB7S2-0006ZC-SY@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Remove unnecessary relcache flushes after changing btree metapages.

These flushes were added in my commit d2896a9ed, which added the btree
logic that keeps a cached copy of the index metapage data in index relcache
entries.  The idea was to ensure that other backends would promptly update
their cached copies after a change.  However, this is not really necessary,
since _bt_getroot() has adequate defenses against believing a stale root
page link, and _bt_getrootheight() doesn't have to be 100% right.
Moreover, if it were necessary, a relcache flush would be an unreliable way
to do it, since the sinval mechanism believes that relcache flush requests
represent transactional updates, and therefore discards them on transaction
rollback.  Therefore, we might as well drop these flush requests and save
the time to rebuild the whole relcache entry after a metapage change.

If we ever try to support in-place truncation of btree indexes, it might
be necessary to revisit this issue so that _bt_getroot() can't get caught
by trying to follow a metapage link to a page that no longer exists.
A possible solution to that is to make use of an smgr, rather than
relcache, inval request to force other backends to discard their cached
metapages.  But for the moment this is not worth pursuing.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/ac8bc3b6e4a28cf7cd33fe11866d72f6deb2a38f

Modified Files
--------------
src/backend/access/nbtree/README      |   19 +++++++++++--------
src/backend/access/nbtree/nbtinsert.c |   11 +----------
src/backend/access/nbtree/nbtpage.c   |   13 ++-----------
src/backend/access/nbtree/nbtree.c    |    8 --------
4 files changed, 14 insertions(+), 37 deletions(-)


pgsql-committers by date:

Previous
From: Robert Haas
Date:
Subject: Re: pgsql: Introduce replication slots.
Next
From: Peter Eisentraut
Date:
Subject: pgsql: Fix whitespace