Skip to content

Commit 845ac7f

Browse files
committed
C comments: improve description of GiST NSN and GistBuildLSN
GiST indexes are complex, so adding more details in the code might help someone. Discussion: https://postgr.es/m/20210302164021.GA364@momjian.us
1 parent d872510 commit 845ac7f

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/backend/access/gist/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ GiST stands for Generalized Search Tree. It was introduced in the seminal paper
1010
Jeffrey F. Naughton, Avi Pfeffer:
1111

1212
http://www.sai.msu.su/~megera/postgres/gist/papers/gist.ps
13+
https://dsf.berkeley.edu/papers/sigmod97-gist.pdf
1314

1415
and implemented by J. Hellerstein and P. Aoki in an early version of
1516
PostgreSQL (more details are available from The GiST Indexing Project

src/include/access/gist.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,20 @@
5151
#define F_HAS_GARBAGE (1 << 4) /* some tuples on the page are dead,
5252
* but not deleted yet */
5353

54-
/* NSN - node sequence number, a special-purpose LSN */
54+
/*
55+
* NSN (node sequence number) is a special-purpose LSN which is stored on each
56+
* index page in GISTPageOpaqueData and updated only during page splits. By
57+
* recording the parent's LSN in GISTSearchItem.parentlsn, it is possible to
58+
* detect concurrent child page splits by checking if parentlsn < child's NSN,
59+
* and handle them properly. The child page's LSN is insufficient for this
60+
* purpose since it is updated for every page change.
61+
*/
5562
typedef XLogRecPtr GistNSN;
5663

5764
/*
58-
* A bogus LSN / NSN value used during index build. Must be smaller than any
59-
* real or fake unlogged LSN, so that after an index build finishes, all the
60-
* splits are considered completed.
65+
* A fake LSN / NSN value used during index builds. Must be smaller than any
66+
* real or fake (unlogged) LSN generated after the index build completes so
67+
* that all splits are considered complete.
6168
*/
6269
#define GistBuildLSN ((XLogRecPtr) 1)
6370

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy