Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2a67d64

Browse files
committed
Add commentary explaining why MaxIndexTuplesPerPage calculation is safe.
MaxIndexTuplesPerPage ignores the fact that btree indexes sometimesstore tuples with no data payload. But it also ignores the possibilityof "special space" on index pages, which offsets that, so that theresult isn't an underestimate. This all seems worth documenting, though.In passing, remove #define MinIndexTupleSize, which was added bycommit2c03216 but not used in that commit nor later ones.Comment text by me; issue noticed by Peter Geoghegan.Discussion:https://postgr.es/m/CAH2-WzkQmb54Kbx-YHXstRKXcNc+_87jwV3DRb54xcybLR7Oig@mail.gmail.com
1 parente013288 commit2a67d64

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

‎src/include/access/itup.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,16 @@ typedef IndexAttributeBitMapData * IndexAttributeBitMap;
132132
* bitmap, so we can safely assume it's at least 1 byte bigger than a bare
133133
* IndexTupleData struct. We arrive at the divisor because each tuple
134134
* must be maxaligned, and it must have an associated item pointer.
135+
*
136+
* To be index-type-independent, this does not account for any special space
137+
* on the page, and is thus conservative.
138+
*
139+
* Note: in btree non-leaf pages, the first tuple has no key (it's implicitly
140+
* minus infinity), thus breaking the "at least 1 byte bigger" assumption.
141+
* On such a page, N tuples could take one MAXALIGN quantum less space than
142+
* estimated here, seemingly allowing one more tuple than estimated here.
143+
* But such a page always has at least MAXALIGN special space, so we're safe.
135144
*/
136-
#defineMinIndexTupleSize MAXALIGN(sizeof(IndexTupleData) + 1)
137145
#defineMaxIndexTuplesPerPage\
138146
((int) ((BLCKSZ - SizeOfPageHeaderData) / \
139147
(MAXALIGN(sizeof(IndexTupleData) + 1) + sizeof(ItemIdData))))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp