MinIndexTupleSize seems slightly wrong

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: MinIndexTupleSize seems slightly wrong
Date: 2018-04-13 00:26:33
Message-ID: CAH2-WzkQmb54Kbx-YHXstRKXcNc+_87jwV3DRb54xcybLR7Oig@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

itup.h says of MinIndexTupleSize/MaxIndexTuplesPerPage:

/*
* MaxIndexTuplesPerPage is an upper bound on the number of tuples that can
* fit on one index page. An index tuple must have either data or a null
* bitmap, so we can safely assume it's at least 1 byte bigger than a bare
* IndexTupleData struct. We arrive at the divisor because each tuple
* must be maxaligned, and it must have an associated item pointer.
*/
#define MinIndexTupleSize MAXALIGN(sizeof(IndexTupleData) + 1)
#define MaxIndexTuplesPerPage \
((int) ((BLCKSZ - SizeOfPageHeaderData) / \
(MAXALIGN(sizeof(IndexTupleData) + 1) + sizeof(ItemIdData))))

However, that at least seems questionable to me. See _bt_pgaddtup()
for a simple example of this -- "minus infinity" items on internal
pages are sized sizeof(IndexTupleData).

The code still seems fine to me, since that only happens at most once
per page. Is it worth noting the exception?

--
Peter Geoghegan

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2018-04-13 01:21:45 Re: Instability in partition_prune test?
Previous Message Michael Paquier 2018-04-12 23:08:13 Re: Native partitioning tablespace inheritance