diff -cpr head/src/backend/commands/vacuum.c remove_PageFreeSpaceInfo/src/backend/commands/vacuum.c
*** head/src/backend/commands/vacuum.c	Thu Aug  2 07:45:08 2007
--- remove_PageFreeSpaceInfo/src/backend/commands/vacuum.c	Mon Aug 13 11:41:10 2007
*************** vac_update_fsm(Relation onerel, VacPageL
*** 3221,3227 ****
  	int			nPages = fraged_pages->num_pages;
  	VacPage    *pagedesc = fraged_pages->pagedesc;
  	Size		threshold;
! 	PageFreeSpaceInfo *pageSpaces;
  	int			outPages;
  	int			i;
  
--- 3221,3227 ----
  	int			nPages = fraged_pages->num_pages;
  	VacPage    *pagedesc = fraged_pages->pagedesc;
  	Size		threshold;
! 	FSMPageData *pageSpaces;
  	int			outPages;
  	int			i;
  
*************** vac_update_fsm(Relation onerel, VacPageL
*** 3237,3244 ****
  	 */
  	threshold = GetAvgFSMRequestSize(&onerel->rd_node);
  
! 	pageSpaces = (PageFreeSpaceInfo *)
! 		palloc(nPages * sizeof(PageFreeSpaceInfo));
  	outPages = 0;
  
  	for (i = 0; i < nPages; i++)
--- 3237,3244 ----
  	 */
  	threshold = GetAvgFSMRequestSize(&onerel->rd_node);
  
! 	pageSpaces = (FSMPageData *)
! 		palloc(nPages * sizeof(FSMPageData));
  	outPages = 0;
  
  	for (i = 0; i < nPages; i++)
*************** vac_update_fsm(Relation onerel, VacPageL
*** 3253,3260 ****
  
  		if (pagedesc[i]->free >= threshold)
  		{
! 			pageSpaces[outPages].blkno = pagedesc[i]->blkno;
! 			pageSpaces[outPages].avail = pagedesc[i]->free;
  			outPages++;
  		}
  	}
--- 3253,3260 ----
  
  		if (pagedesc[i]->free >= threshold)
  		{
! 			FSMPageSetPageNum(&pageSpaces[outPages], pagedesc[i]->blkno);
! 			FSMPageSetSpace(&pageSpaces[outPages], pagedesc[i]->free);
  			outPages++;
  		}
  	}
diff -cpr head/src/backend/commands/vacuumlazy.c remove_PageFreeSpaceInfo/src/backend/commands/vacuumlazy.c
*** head/src/backend/commands/vacuumlazy.c	Thu May 31 05:11:57 2007
--- remove_PageFreeSpaceInfo/src/backend/commands/vacuumlazy.c	Mon Aug 13 11:41:10 2007
*************** typedef struct LVRelStats
*** 90,96 ****
  	bool		fs_is_heap;		/* are we using heap organization? */
  	int			num_free_pages; /* current # of entries */
  	int			max_free_pages; /* # slots allocated in array */
! 	PageFreeSpaceInfo *free_pages;		/* array or heap of blkno/avail */
  	BlockNumber tot_free_pages; /* total pages with >= threshold space */
  	int			num_index_scans;
  } LVRelStats;
--- 90,96 ----
  	bool		fs_is_heap;		/* are we using heap organization? */
  	int			num_free_pages; /* current # of entries */
  	int			max_free_pages; /* # slots allocated in array */
! 	FSMPageData *free_pages;		/* array or heap of blkno/avail */
  	BlockNumber tot_free_pages; /* total pages with >= threshold space */
  	int			num_index_scans;
  } LVRelStats;
*************** lazy_truncate_heap(Relation onerel, LVRe
*** 756,762 ****
  {
  	BlockNumber old_rel_pages = vacrelstats->rel_pages;
  	BlockNumber new_rel_pages;
! 	PageFreeSpaceInfo *pageSpaces;
  	int			n;
  	int			i,
  				j;
--- 756,762 ----
  {
  	BlockNumber old_rel_pages = vacrelstats->rel_pages;
  	BlockNumber new_rel_pages;
! 	FSMPageData *pageSpaces;
  	int			n;
  	int			i,
  				j;
*************** lazy_truncate_heap(Relation onerel, LVRe
*** 816,822 ****
  	j = 0;
  	for (i = 0; i < n; i++)
  	{
! 		if (pageSpaces[i].blkno < new_rel_pages)
  		{
  			pageSpaces[j] = pageSpaces[i];
  			j++;
--- 816,822 ----
  	j = 0;
  	for (i = 0; i < n; i++)
  	{
! 		if (FSMPageGetPageNum(&pageSpaces[i]) < new_rel_pages)
  		{
  			pageSpaces[j] = pageSpaces[i];
  			j++;
*************** lazy_space_alloc(LVRelStats *vacrelstats
*** 988,994 ****
  		palloc(maxtuples * sizeof(ItemPointerData));
  
  	maxpages = MaxFSMPages;
! 	maxpages = Min(maxpages, MaxAllocSize / sizeof(PageFreeSpaceInfo));
  	/* No need to allocate more pages than the relation has blocks */
  	if (relblocks < (BlockNumber) maxpages)
  		maxpages = (int) relblocks;
--- 988,994 ----
  		palloc(maxtuples * sizeof(ItemPointerData));
  
  	maxpages = MaxFSMPages;
! 	maxpages = Min(maxpages, MaxAllocSize / sizeof(FSMPageData));
  	/* No need to allocate more pages than the relation has blocks */
  	if (relblocks < (BlockNumber) maxpages)
  		maxpages = (int) relblocks;
*************** lazy_space_alloc(LVRelStats *vacrelstats
*** 996,1003 ****
  	vacrelstats->fs_is_heap = false;
  	vacrelstats->num_free_pages = 0;
  	vacrelstats->max_free_pages = maxpages;
! 	vacrelstats->free_pages = (PageFreeSpaceInfo *)
! 		palloc(maxpages * sizeof(PageFreeSpaceInfo));
  	vacrelstats->tot_free_pages = 0;
  }
  
--- 996,1003 ----
  	vacrelstats->fs_is_heap = false;
  	vacrelstats->num_free_pages = 0;
  	vacrelstats->max_free_pages = maxpages;
! 	vacrelstats->free_pages = (FSMPageData *)
! 		palloc(maxpages * sizeof(FSMPageData));
  	vacrelstats->tot_free_pages = 0;
  }
  
*************** lazy_record_free_space(LVRelStats *vacre
*** 1028,1034 ****
  					   BlockNumber page,
  					   Size avail)
  {
! 	PageFreeSpaceInfo *pageSpaces;
  	int			n;
  
  	/*
--- 1028,1034 ----
  					   BlockNumber page,
  					   Size avail)
  {
! 	FSMPageData *pageSpaces;
  	int			n;
  
  	/*
*************** lazy_record_free_space(LVRelStats *vacre
*** 1058,1065 ****
  	/* If we haven't filled the array yet, just keep adding entries */
  	if (vacrelstats->num_free_pages < n)
  	{
! 		pageSpaces[vacrelstats->num_free_pages].blkno = page;
! 		pageSpaces[vacrelstats->num_free_pages].avail = avail;
  		vacrelstats->num_free_pages++;
  		return;
  	}
--- 1058,1065 ----
  	/* If we haven't filled the array yet, just keep adding entries */
  	if (vacrelstats->num_free_pages < n)
  	{
! 		FSMPageSetPageNum(&pageSpaces[vacrelstats->num_free_pages], page);
! 		FSMPageSetSpace(&pageSpaces[vacrelstats->num_free_pages], avail);
  		vacrelstats->num_free_pages++;
  		return;
  	}
*************** lazy_record_free_space(LVRelStats *vacre
*** 1087,1094 ****
  
  		while (--l >= 0)
  		{
! 			BlockNumber R = pageSpaces[l].blkno;
! 			Size		K = pageSpaces[l].avail;
  			int			i;		/* i is where the "hole" is */
  
  			i = l;
--- 1087,1094 ----
  
  		while (--l >= 0)
  		{
! 			BlockNumber R = FSMPageGetPageNum(&pageSpaces[l]);
! 			Size		K = FSMPageGetSpace(&pageSpaces[l]);
  			int			i;		/* i is where the "hole" is */
  
  			i = l;
*************** lazy_record_free_space(LVRelStats *vacre
*** 1098,1119 ****
  
  				if (j >= n)
  					break;
! 				if (j + 1 < n && pageSpaces[j].avail > pageSpaces[j + 1].avail)
  					j++;
! 				if (K <= pageSpaces[j].avail)
  					break;
  				pageSpaces[i] = pageSpaces[j];
  				i = j;
  			}
! 			pageSpaces[i].blkno = R;
! 			pageSpaces[i].avail = K;
  		}
  
  		vacrelstats->fs_is_heap = true;
  	}
  
  	/* If new page has more than zero'th entry, insert it into heap */
! 	if (avail > pageSpaces[0].avail)
  	{
  		/*
  		 * Notionally, we replace the zero'th entry with the new data, and
--- 1098,1119 ----
  
  				if (j >= n)
  					break;
! 				if (j + 1 < n && FSMPageGetSpace(&pageSpaces[j]) > FSMPageGetSpace(&pageSpaces[j + 1]))
  					j++;
! 				if (K <= FSMPageGetSpace(&pageSpaces[j]))
  					break;
  				pageSpaces[i] = pageSpaces[j];
  				i = j;
  			}
! 			FSMPageSetPageNum(&pageSpaces[i], R);
! 			FSMPageSetSpace(&pageSpaces[i], K);
  		}
  
  		vacrelstats->fs_is_heap = true;
  	}
  
  	/* If new page has more than zero'th entry, insert it into heap */
! 	if (avail > FSMPageGetSpace(&pageSpaces[0]))
  	{
  		/*
  		 * Notionally, we replace the zero'th entry with the new data, and
*************** lazy_record_free_space(LVRelStats *vacre
*** 1129,1143 ****
  
  			if (j >= n)
  				break;
! 			if (j + 1 < n && pageSpaces[j].avail > pageSpaces[j + 1].avail)
  				j++;
! 			if (avail <= pageSpaces[j].avail)
  				break;
  			pageSpaces[i] = pageSpaces[j];
  			i = j;
  		}
! 		pageSpaces[i].blkno = page;
! 		pageSpaces[i].avail = avail;
  	}
  }
  
--- 1129,1143 ----
  
  			if (j >= n)
  				break;
! 			if (j + 1 < n && FSMPageGetSpace(&pageSpaces[j]) > FSMPageGetSpace(&pageSpaces[j + 1]))
  				j++;
! 			if (avail <= FSMPageGetSpace(&pageSpaces[j]))
  				break;
  			pageSpaces[i] = pageSpaces[j];
  			i = j;
  		}
! 		FSMPageSetPageNum(&pageSpaces[i], page);
! 		FSMPageSetSpace(&pageSpaces[i], avail);
  	}
  }
  
*************** lazy_tid_reaped(ItemPointer itemptr, voi
*** 1170,1183 ****
  static void
  lazy_update_fsm(Relation onerel, LVRelStats *vacrelstats)
  {
! 	PageFreeSpaceInfo *pageSpaces = vacrelstats->free_pages;
  	int			nPages = vacrelstats->num_free_pages;
  
  	/*
  	 * Sort data into order, as required by RecordRelationFreeSpace.
  	 */
  	if (nPages > 1)
! 		qsort(pageSpaces, nPages, sizeof(PageFreeSpaceInfo),
  			  vac_cmp_page_spaces);
  
  	RecordRelationFreeSpace(&onerel->rd_node, vacrelstats->tot_free_pages,
--- 1170,1183 ----
  static void
  lazy_update_fsm(Relation onerel, LVRelStats *vacrelstats)
  {
! 	FSMPageData *pageSpaces = vacrelstats->free_pages;
  	int			nPages = vacrelstats->num_free_pages;
  
  	/*
  	 * Sort data into order, as required by RecordRelationFreeSpace.
  	 */
  	if (nPages > 1)
! 		qsort(pageSpaces, nPages, sizeof(FSMPageData),
  			  vac_cmp_page_spaces);
  
  	RecordRelationFreeSpace(&onerel->rd_node, vacrelstats->tot_free_pages,
*************** vac_cmp_itemptr(const void *left, const 
*** 1217,1228 ****
  static int
  vac_cmp_page_spaces(const void *left, const void *right)
  {
! 	PageFreeSpaceInfo *linfo = (PageFreeSpaceInfo *) left;
! 	PageFreeSpaceInfo *rinfo = (PageFreeSpaceInfo *) right;
  
! 	if (linfo->blkno < rinfo->blkno)
  		return -1;
! 	else if (linfo->blkno > rinfo->blkno)
  		return 1;
  	return 0;
  }
--- 1217,1230 ----
  static int
  vac_cmp_page_spaces(const void *left, const void *right)
  {
! 	FSMPageData *linfo = (FSMPageData *) left;
! 	FSMPageData *rinfo = (FSMPageData *) right;
! 	BlockNumber	lblkno = FSMPageGetPageNum(linfo);
! 	BlockNumber	rblkno = FSMPageGetPageNum(rinfo);
  
! 	if (lblkno < rblkno)
  		return -1;
! 	else if (lblkno > rblkno)
  		return 1;
  	return 0;
  }
diff -cpr head/src/backend/storage/freespace/freespace.c remove_PageFreeSpaceInfo/src/backend/storage/freespace/freespace.c
*** head/src/backend/storage/freespace/freespace.c	Sat Jan  6 07:19:37 2007
--- remove_PageFreeSpaceInfo/src/backend/storage/freespace/freespace.c	Mon Aug 13 11:41:10 2007
*************** static bool lookup_fsm_page_entry(FSMRel
*** 143,149 ****
  static void compact_fsm_storage(void);
  static void push_fsm_rels_after(FSMRelation *afterRel);
  static void pack_incoming_pages(FSMPageData *newLocation, int newPages,
! 					PageFreeSpaceInfo *pageSpaces, int nPages);
  static void pack_existing_pages(FSMPageData *newLocation, int newPages,
  					FSMPageData *oldLocation, int oldPages);
  static int	fsm_calc_request(FSMRelation *fsmrel);
--- 143,149 ----
  static void compact_fsm_storage(void);
  static void push_fsm_rels_after(FSMRelation *afterRel);
  static void pack_incoming_pages(FSMPageData *newLocation, int newPages,
! 					FSMPageData *pageSpaces, int nPages);
  static void pack_existing_pages(FSMPageData *newLocation, int newPages,
  					FSMPageData *oldLocation, int oldPages);
  static int	fsm_calc_request(FSMRelation *fsmrel);
*************** void
*** 375,381 ****
  RecordRelationFreeSpace(RelFileNode *rel,
  						BlockNumber interestingPages,
  						int nPages,
! 						PageFreeSpaceInfo *pageSpaces)
  {
  	FSMRelation *fsmrel;
  
--- 375,381 ----
  RecordRelationFreeSpace(RelFileNode *rel,
  						BlockNumber interestingPages,
  						int nPages,
! 						FSMPageData *pageSpaces)
  {
  	FSMRelation *fsmrel;
  
*************** RecordRelationFreeSpace(RelFileNode *rel
*** 415,428 ****
  
  			for (i = 0; i < nPages; i++)
  			{
! 				BlockNumber page = pageSpaces[i].blkno;
! 				Size		avail = pageSpaces[i].avail;
  
  				/* Check caller provides sorted data */
! 				if (i > 0 && page <= pageSpaces[i - 1].blkno)
  					elog(ERROR, "free-space data is not in page order");
! 				FSMPageSetPageNum(newLocation, page);
! 				FSMPageSetSpace(newLocation, avail);
  				newLocation++;
  			}
  			fsmrel->storedPages = nPages;
--- 415,426 ----
  
  			for (i = 0; i < nPages; i++)
  			{
! 				BlockNumber page = FSMPageGetPageNum(&pageSpaces[i]);
  
  				/* Check caller provides sorted data */
! 				if (i > 0 && page <= FSMPageGetPageNum(&pageSpaces[i - 1]))
  					elog(ERROR, "free-space data is not in page order");
! 				*newLocation = pageSpaces[i];
  				newLocation++;
  			}
  			fsmrel->storedPages = nPages;
*************** push_fsm_rels_after(FSMRelation *afterRe
*** 1534,1540 ****
  
  static void
  pack_incoming_pages(FSMPageData *newLocation, int newPages,
! 					PageFreeSpaceInfo *pageSpaces, int nPages)
  {
  	int			histogram[HISTOGRAM_BINS];
  	int			above,
--- 1532,1538 ----
  
  static void
  pack_incoming_pages(FSMPageData *newLocation, int newPages,
! 					FSMPageData *pageSpaces, int nPages)
  {
  	int			histogram[HISTOGRAM_BINS];
  	int			above,
*************** pack_incoming_pages(FSMPageData *newLoca
*** 1548,1554 ****
  	MemSet(histogram, 0, sizeof(histogram));
  	for (i = 0; i < nPages; i++)
  	{
! 		Size		avail = pageSpaces[i].avail;
  
  		if (avail >= BLCKSZ)
  			elog(ERROR, "bogus freespace amount");
--- 1546,1552 ----
  	MemSet(histogram, 0, sizeof(histogram));
  	for (i = 0; i < nPages; i++)
  	{
! 		Size		avail = FSMPageGetSpace(&pageSpaces[i]);
  
  		if (avail >= BLCKSZ)
  			elog(ERROR, "bogus freespace amount");
*************** pack_incoming_pages(FSMPageData *newLoca
*** 1572,1589 ****
  	/* And copy the appropriate data */
  	for (i = 0; i < nPages; i++)
  	{
! 		BlockNumber page = pageSpaces[i].blkno;
! 		Size		avail = pageSpaces[i].avail;
  
  		/* Check caller provides sorted data */
! 		if (i > 0 && page <= pageSpaces[i - 1].blkno)
  			elog(ERROR, "free-space data is not in page order");
  		/* Save this page? */
  		if (avail >= thresholdU ||
  			(avail >= thresholdL && (--binct >= 0)))
  		{
! 			FSMPageSetPageNum(newLocation, page);
! 			FSMPageSetSpace(newLocation, avail);
  			newLocation++;
  			newPages--;
  		}
--- 1570,1586 ----
  	/* And copy the appropriate data */
  	for (i = 0; i < nPages; i++)
  	{
! 		BlockNumber	page = FSMPageGetPageNum(&pageSpaces[i]);
! 		Size		avail = FSMPageGetSpace(&pageSpaces[i]);
  
  		/* Check caller provides sorted data */
! 		if (i > 0 && page <= FSMPageGetPageNum(&pageSpaces[i - 1]))
  			elog(ERROR, "free-space data is not in page order");
  		/* Save this page? */
  		if (avail >= thresholdU ||
  			(avail >= thresholdL && (--binct >= 0)))
  		{
! 			*newLocation = pageSpaces[i];
  			newLocation++;
  			newPages--;
  		}
diff -cpr head/src/include/storage/freespace.h remove_PageFreeSpaceInfo/src/include/storage/freespace.h
*** head/src/include/storage/freespace.h	Wed Jul 25 21:22:53 2007
--- remove_PageFreeSpaceInfo/src/include/storage/freespace.h	Mon Aug 13 11:41:10 2007
***************
*** 18,33 ****
  #include "storage/itemptr.h"
  
  
- /*
-  * exported types
-  */
- typedef struct PageFreeSpaceInfo
- {
- 	BlockNumber blkno;			/* which page in relation */
- 	Size		avail;			/* space available on this page */
- } PageFreeSpaceInfo;
- 
- 
  /* Initial value for average-request moving average */
  #define INITIAL_AVERAGE ((Size) (BLCKSZ / 32))
  
--- 18,23 ----
*************** extern Size GetAvgFSMRequestSize(RelFile
*** 144,150 ****
  extern void RecordRelationFreeSpace(RelFileNode *rel,
  						BlockNumber interestingPages,
  						int nPages,
! 						PageFreeSpaceInfo *pageSpaces);
  
  extern BlockNumber GetFreeIndexPage(RelFileNode *rel);
  extern void RecordIndexFreeSpace(RelFileNode *rel,
--- 134,140 ----
  extern void RecordRelationFreeSpace(RelFileNode *rel,
  						BlockNumber interestingPages,
  						int nPages,
! 						FSMPageData *pageSpaces);
  
  extern BlockNumber GetFreeIndexPage(RelFileNode *rel);
  extern void RecordIndexFreeSpace(RelFileNode *rel,