mirror of
https://github.com/zebrajr/postgres.git
synced 2025-12-07 12:20:31 +01:00
This adds a new optional support function to the GiST access method: sortsupport. If it is defined, the GiST index is built by sorting all data to the order defined by the sortsupport's comparator function, and packing the tuples in that order to GiST pages. This is similar to how B-tree index build works, and is much faster than inserting the tuples one by one. The resulting index is smaller too, because the pages are packed more tightly, upto 'fillfactor'. The normal build method works by splitting pages, which tends to lead to more wasted space. The quality of the resulting index depends on how good the opclass-defined sort order is. A good order preserves locality of the input data. As the first user of this facility, add 'sortsupport' function to the point_ops opclass. It sorts the points in Z-order (aka Morton Code), by interleaving the bits of the X and Y coordinates. Author: Andrey Borodin Reviewed-by: Pavel Borisov, Thomas Munro Discussion: https://www.postgresql.org/message-id/1A36620E-CAD8-4267-9067-FB31385E7C0D%40yandex-team.ru
67 lines
2.6 KiB
C
67 lines
2.6 KiB
C
/*
|
|
* xloginsert.h
|
|
*
|
|
* Functions for generating WAL records
|
|
*
|
|
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* src/include/access/xloginsert.h
|
|
*/
|
|
#ifndef XLOGINSERT_H
|
|
#define XLOGINSERT_H
|
|
|
|
#include "access/rmgr.h"
|
|
#include "access/xlogdefs.h"
|
|
#include "storage/block.h"
|
|
#include "storage/buf.h"
|
|
#include "storage/relfilenode.h"
|
|
#include "utils/relcache.h"
|
|
|
|
/*
|
|
* The minimum size of the WAL construction working area. If you need to
|
|
* register more than XLR_NORMAL_MAX_BLOCK_ID block references or have more
|
|
* than XLR_NORMAL_RDATAS data chunks in a single WAL record, you must call
|
|
* XLogEnsureRecordSpace() first to allocate more working memory.
|
|
*/
|
|
#define XLR_NORMAL_MAX_BLOCK_ID 4
|
|
#define XLR_NORMAL_RDATAS 20
|
|
|
|
/* flags for XLogRegisterBuffer */
|
|
#define REGBUF_FORCE_IMAGE 0x01 /* force a full-page image */
|
|
#define REGBUF_NO_IMAGE 0x02 /* don't take a full-page image */
|
|
#define REGBUF_WILL_INIT (0x04 | 0x02) /* page will be re-initialized at
|
|
* replay (implies NO_IMAGE) */
|
|
#define REGBUF_STANDARD 0x08 /* page follows "standard" page layout,
|
|
* (data between pd_lower and pd_upper
|
|
* will be skipped) */
|
|
#define REGBUF_KEEP_DATA 0x10 /* include data even if a full-page image
|
|
* is taken */
|
|
|
|
/* prototypes for public functions in xloginsert.c: */
|
|
extern void XLogBeginInsert(void);
|
|
extern void XLogSetRecordFlags(uint8 flags);
|
|
extern XLogRecPtr XLogInsert(RmgrId rmid, uint8 info);
|
|
extern void XLogEnsureRecordSpace(int max_block_id, int ndatas);
|
|
extern void XLogRegisterData(char *data, int len);
|
|
extern void XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags);
|
|
extern void XLogRegisterBlock(uint8 block_id, RelFileNode *rnode,
|
|
ForkNumber forknum, BlockNumber blknum, char *page,
|
|
uint8 flags);
|
|
extern void XLogRegisterBufData(uint8 block_id, char *data, int len);
|
|
extern void XLogResetInsertion(void);
|
|
extern bool XLogCheckBufferNeedsBackup(Buffer buffer);
|
|
|
|
extern XLogRecPtr log_newpage(RelFileNode *rnode, ForkNumber forkNum,
|
|
BlockNumber blk, char *page, bool page_std);
|
|
extern void log_newpages(RelFileNode *rnode, ForkNumber forkNum, int num_pages,
|
|
BlockNumber *blknos, char **pages, bool page_std);
|
|
extern XLogRecPtr log_newpage_buffer(Buffer buffer, bool page_std);
|
|
extern void log_newpage_range(Relation rel, ForkNumber forkNum,
|
|
BlockNumber startblk, BlockNumber endblk, bool page_std);
|
|
extern XLogRecPtr XLogSaveBufferForHint(Buffer buffer, bool buffer_std);
|
|
|
|
extern void InitXLogInsert(void);
|
|
|
|
#endif /* XLOGINSERT_H */
|