mirror of
https://github.com/postgres/postgres.git
synced 2025-08-18 12:22:09 +03:00
Compress GIN posting lists, for smaller index size.
GIN posting lists are now encoded using varbyte-encoding, which allows them to fit in much smaller space than the straight ItemPointer array format used before. The new encoding is used for both the lists stored in-line in entry tree items, and in posting tree leaf pages. To maintain backwards-compatibility and keep pg_upgrade working, the code can still read old-style pages and tuples. Posting tree leaf pages in the new format are flagged with GIN_COMPRESSED flag, to distinguish old and new format pages. Likewise, entry tree tuples in the new format have a GIN_ITUP_COMPRESSED flag set in a bit that was previously unused. This patch bumps GIN_CURRENT_VERSION from 1 to 2. New indexes created with version 9.4 will therefore have version number 2 in the metapage, while old pg_upgraded indexes will have version 1. The code treats them the same, but it might be come handy in the future, if we want to drop support for the uncompressed format. Alexander Korotkov and me. Reviewed by Tomas Vondra and Amit Langote.
This commit is contained in:
@@ -47,8 +47,7 @@ gin_desc(StringInfo buf, uint8 xl_info, char *rec)
|
||||
|
||||
appendStringInfoString(buf, "Insert item, ");
|
||||
desc_node(buf, xlrec->node, xlrec->blkno);
|
||||
appendStringInfo(buf, " offset: %u isdata: %c isleaf: %c",
|
||||
xlrec->offset,
|
||||
appendStringInfo(buf, " isdata: %c isleaf: %c",
|
||||
(xlrec->flags & GIN_INSERT_ISDATA) ? 'T' : 'F',
|
||||
(xlrec->flags & GIN_INSERT_ISLEAF) ? 'T' : 'F');
|
||||
if (!(xlrec->flags & GIN_INSERT_ISLEAF))
|
||||
@@ -67,24 +66,50 @@ gin_desc(StringInfo buf, uint8 xl_info, char *rec)
|
||||
appendStringInfo(buf, " isdelete: %c",
|
||||
(((ginxlogInsertEntry *) payload)->isDelete) ? 'T' : 'F');
|
||||
else if (xlrec->flags & GIN_INSERT_ISLEAF)
|
||||
appendStringInfo(buf, " nitem: %u",
|
||||
(((ginxlogInsertDataLeaf *) payload)->nitem));
|
||||
{
|
||||
ginxlogRecompressDataLeaf *insertData =
|
||||
(ginxlogRecompressDataLeaf *) payload;
|
||||
|
||||
appendStringInfo(buf, " unmodified: %u length: %u (compressed)",
|
||||
insertData->unmodifiedsize,
|
||||
insertData->length);
|
||||
}
|
||||
else
|
||||
{
|
||||
ginxlogInsertDataInternal *insertData = (ginxlogInsertDataInternal *) payload;
|
||||
appendStringInfo(buf, " pitem: %u-%u/%u",
|
||||
PostingItemGetBlockNumber((PostingItem *) payload),
|
||||
ItemPointerGetBlockNumber(&((PostingItem *) payload)->key),
|
||||
ItemPointerGetOffsetNumber(&((PostingItem *) payload)->key));
|
||||
PostingItemGetBlockNumber(&insertData->newitem),
|
||||
ItemPointerGetBlockNumber(&insertData->newitem.key),
|
||||
ItemPointerGetOffsetNumber(&insertData->newitem.key));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case XLOG_GIN_SPLIT:
|
||||
appendStringInfoString(buf, "Page split, ");
|
||||
desc_node(buf, ((ginxlogSplit *) rec)->node, ((ginxlogSplit *) rec)->lblkno);
|
||||
appendStringInfo(buf, " isrootsplit: %c", (((ginxlogSplit *) rec)->flags & GIN_SPLIT_ROOT) ? 'T' : 'F');
|
||||
{
|
||||
ginxlogSplit *xlrec = (ginxlogSplit *) rec;
|
||||
|
||||
appendStringInfoString(buf, "Page split, ");
|
||||
desc_node(buf, ((ginxlogSplit *) rec)->node, ((ginxlogSplit *) rec)->lblkno);
|
||||
appendStringInfo(buf, " isrootsplit: %c", (((ginxlogSplit *) rec)->flags & GIN_SPLIT_ROOT) ? 'T' : 'F');
|
||||
appendStringInfo(buf, " isdata: %c isleaf: %c",
|
||||
(xlrec->flags & GIN_INSERT_ISDATA) ? 'T' : 'F',
|
||||
(xlrec->flags & GIN_INSERT_ISLEAF) ? 'T' : 'F');
|
||||
}
|
||||
break;
|
||||
case XLOG_GIN_VACUUM_PAGE:
|
||||
appendStringInfoString(buf, "Vacuum page, ");
|
||||
desc_node(buf, ((ginxlogVacuumPage *) rec)->node, ((ginxlogVacuumPage *) rec)->blkno);
|
||||
break;
|
||||
case XLOG_GIN_VACUUM_DATA_LEAF_PAGE:
|
||||
{
|
||||
ginxlogVacuumDataLeafPage *xlrec = (ginxlogVacuumDataLeafPage *) rec;
|
||||
appendStringInfoString(buf, "Vacuum data leaf page, ");
|
||||
desc_node(buf, xlrec->node, xlrec->blkno);
|
||||
appendStringInfo(buf, " unmodified: %u length: %u",
|
||||
xlrec->data.unmodifiedsize,
|
||||
xlrec->data.length);
|
||||
}
|
||||
break;
|
||||
case XLOG_GIN_DELETE_PAGE:
|
||||
appendStringInfoString(buf, "Delete page, ");
|
||||
desc_node(buf, ((ginxlogDeletePage *) rec)->node, ((ginxlogDeletePage *) rec)->blkno);
|
||||
|
Reference in New Issue
Block a user