mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-11 22:57:40 +08:00
on non-full-page-image WAL records, and quite arbitrarily, only if there's less than 20% free space on the page after the insert/update (not on HOT updates, though). The 20% cutoff should avoid most of the overhead, when replaying a bulk insertion, for example, while ensuring that pages that are full are marked as full in the FSM. This is mostly to avoid the nasty worst case scenario, where you replay from a PITR archive, and the FSM information in the base backup is really out of date. If there was a lot of pages that the outdated FSM claims to have free space, but don't actually have any, the first unlucky inserter after the recovery would traverse through all those pages, just to find out that they're full. We didn't have this problem with the old FSM implementation, because we simply threw the FSM information away on a non-clean shutdown.
41 lines
1.4 KiB
C
41 lines
1.4 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* freespace.h
|
|
* POSTGRES free space map for quickly finding free space in relations
|
|
*
|
|
*
|
|
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* $PostgreSQL: pgsql/src/include/storage/freespace.h,v 1.30 2008/10/31 19:40:27 heikki Exp $
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef FREESPACE_H_
|
|
#define FREESPACE_H_
|
|
|
|
#include "utils/rel.h"
|
|
#include "storage/bufpage.h"
|
|
#include "access/xlog.h"
|
|
|
|
/* prototypes for public functions in freespace.c */
|
|
extern Size GetRecordedFreeSpace(Relation rel, BlockNumber heapBlk);
|
|
extern BlockNumber GetPageWithFreeSpace(Relation rel, Size spaceNeeded);
|
|
extern BlockNumber RecordAndGetPageWithFreeSpace(Relation rel,
|
|
BlockNumber oldPage,
|
|
Size oldSpaceAvail,
|
|
Size spaceNeeded);
|
|
extern void RecordPageWithFreeSpace(Relation rel, BlockNumber heapBlk,
|
|
Size spaceAvail);
|
|
extern void XLogRecordPageWithFreeSpace(RelFileNode rnode, BlockNumber heapBlk,
|
|
Size spaceAvail);
|
|
|
|
extern void FreeSpaceMapTruncateRel(Relation rel, BlockNumber nblocks);
|
|
extern void FreeSpaceMapVacuum(Relation rel);
|
|
|
|
/* WAL prototypes */
|
|
extern void fsm_desc(StringInfo buf, uint8 xl_info, char *rec);
|
|
extern void fsm_redo(XLogRecPtr lsn, XLogRecord *record);
|
|
|
|
#endif /* FREESPACE_H */
|