pgsql: Remove unnecessary relcache flushes after changing btree metapag

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Remove unnecessary relcache flushes after changing btree metapag
Date: 2014-02-05 18:43:58
Message-ID: E1WB7S2-0006ZC-SY@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2014-02-06 04:13:31 pgsql: Fix whitespace
Previous Message Robert Haas 2014-02-05 18:42:18 Re: pgsql: Introduce replication slots.