pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <hlinnakangas@vmware.com>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: PostgreSQL-development <pgsql-hackers@postgreSQL.org>
Subject: BRIN page type identifier
Date: Mon, 17 Nov 2014 17:40:31 +0200
Message-ID: <546A16EF.9070005@vmware.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>

The "special" area in a BRIN page looks like this:

> /* special space on all BRIN pages stores a "type" identifier */
> #define		BRIN_PAGETYPE_META			0xF091
> #define		BRIN_PAGETYPE_REVMAP		0xF092
> #define		BRIN_PAGETYPE_REGULAR		0xF093
>...
> typedef struct BrinSpecialSpace
> {
> 	uint16		flags;
> 	uint16		type;
> } BrinSpecialSpace;

I believe this is supposed to follow the usual convention that the last 
two bytes of a page can be used to identify the page type. SP-GiST uses 
0xFF82, while GIN uses values 0x00XX.

However, because the special size is MAXALIGNed, the 'type' field are 
not the last 2 bytes on the page, as intended. I'd suggest just adding 
"char padding[6]"  in BrinSpecialSpace, before 'flags'. That'll waste 4 
bytes on 32-bit systems, but that seems acceptable.

Also, the comment in GinPageOpaqueData needs updating:

> /*
>  * Page opaque data in an inverted index page.
>  *
>  * Note: GIN does not include a page ID word as do the other index types.
>  * This is OK because the opaque data is only 8 bytes and so can be reliably
>  * distinguished by size.  Revisit this if the size ever increases.
>  * Further note: as of 9.2, SP-GiST also uses 8-byte special space.  This is
>  * still OK, as long as GIN isn't using all of the high-order bits in its
>  * flags word, because that way the flags word cannot match the page ID used
>  * by SP-GiST.
>  */

BRIN now also uses 8-byte special space. While you're at it, might want 
to move that comment somewhere else, as it's really about a convention 
among all page types, not just GIN.

- Heikki


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (6+ messages)  latest in thread

Message-ID: <546A16EF.9070005@vmware.com>
Permalink:  ../546A16EF.9070005@vmware.com/
Also on:    postgresql.org/message-id/546A16EF.9070005@vmware.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: hlinnakangas@vmware.com, alvherre@2ndquadrant.com
  Subject: Re: BRIN page type identifier
  In-Reply-To: <546A16EF.9070005@vmware.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox