Skip site navigation (1) Skip section navigation (2)

Reduce per tuple overhead (bitmap)

From: Manfred Koizar <mkoi-pg(at)aon(dot)at>
To: pgsql-patches(at)postgresql(dot)org
Subject: Reduce per tuple overhead (bitmap)
Date: 2002-05-05 15:29:24
Message-ID: 8r8aduobem33cddro4g46hgeqdg42r183g@4ax.com (view raw or flat)
Thread:
Lists: pgsql-patches
This small patch makes the length of the null bitmap a multiple
of 1 byte (has been a multiple of 4 bytes previously), thus saving
MAXIMUM_ALIGNOF (4 or 8 on modern platforms) bytes per on-disk-tuple
in certain cases (depending on number of attributes and if there is
at least one null attribute).

It passes make check for 7.2 and for cvs HEAD.

Though it changes the on-disk-format, there's no need to initdb,
because data offsets are stored in t_hoff for each tuple.  So this
patch can be applied to HEAD and to the 7.2 branch.

Servus
 Manfred


diff -r -u ../orig/src/include/access/htup.h src/include/access/htup.h
--- ../orig/src/include/access/htup.h	Mon Nov  5 18:46:31 2001
+++ src/include/access/htup.h	Sun May  5 08:03:29 2002
@@ -17,7 +17,7 @@
 #include "storage/bufpage.h"
 #include "storage/relfilenode.h"
 
-#define MinHeapTupleBitmapSize	32		/* 8 * 4 */
+#define MinHeapTupleBitmapLen	1	/* in bytes, must be 2**n */
 
 /*
  * MaxHeapAttributeNumber limits the number of (user) columns in a table.
@@ -57,7 +57,7 @@
 
 	/* ^ - 31 bytes - ^ */
 
-	bits8		t_bits[MinHeapTupleBitmapSize / 8];
+	bits8		t_bits[MinHeapTupleBitmapLen];
 	/* bit map of NULLs */
 
 	/* MORE DATA FOLLOWS AT END OF STRUCT */
@@ -225,8 +225,8 @@
  *		Computes minimum size of bitmap given number of domains.
  */
 #define BITMAPLEN(NATTS) \
-		((((((int)(NATTS) - 1) >> 3) + 4 - (MinHeapTupleBitmapSize >> 3)) \
-		  & ~03) + (MinHeapTupleBitmapSize >> 3))
+		(((((int)(NATTS) - 1) >> 3) \
+		  & ~(MinHeapTupleBitmapLen - 1)) + MinHeapTupleBitmapLen)
 
 /*
  * HeapTupleIsValid


Responses

pgsql-patches by date

Next:From: Mike RogersDate: 2002-05-06 02:08:37
Subject: Large PG_DUMPs going into memory?
Previous:From: Tom LaneDate: 2002-05-04 15:36:45
Subject: Re: [PATCHES] Auto-reload of dynamic libraries

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group