row compression & hash index
This commit is contained in:
60
src/common/backend/utils/cache/relcache.cpp
vendored
60
src/common/backend/utils/cache/relcache.cpp
vendored
@ -176,6 +176,7 @@
|
||||
#include "rewrite/rewriteDefine.h"
|
||||
#include "rewrite/rewriteRlsPolicy.h"
|
||||
#include "storage/lmgr.h"
|
||||
#include "storage/page_compression.h"
|
||||
#include "storage/smgr/smgr.h"
|
||||
#include "storage/smgr/segment.h"
|
||||
#include "threadpool/threadpool.h"
|
||||
@ -1284,7 +1285,6 @@ static void IndexSupportInitialize(Relation relation, oidvector* indclass, Strat
|
||||
static OpClassCacheEnt* LookupOpclassInfo(Relation relation, Oid operatorClassOid, StrategyNumber numSupport);
|
||||
static void RelationCacheInitFileRemoveInDir(const char* tblspcpath);
|
||||
static void unlink_initfile(const char* initfilename);
|
||||
|
||||
/*
|
||||
* ScanPgRelation
|
||||
*
|
||||
@ -2499,6 +2499,12 @@ void RelationInitPhysicalAddr(Relation relation)
|
||||
if (!RelationIsPartitioned(relation) && relation->storage_type == SEGMENT_PAGE) {
|
||||
relation->rd_node.bucketNode = SegmentBktId;
|
||||
}
|
||||
|
||||
// setup page compression options
|
||||
relation->rd_node.opt = 0;
|
||||
if (relation->rd_options && REL_SUPPORT_COMPRESSED(relation)) {
|
||||
SetupPageCompressForRelation(&relation->rd_node, &((StdRdOptions*)(relation->rd_options))->compress, RelationGetRelationName(relation));
|
||||
}
|
||||
}
|
||||
|
||||
static void IndexRelationInitKeyNums(Relation relation)
|
||||
@ -4335,8 +4341,9 @@ void AtEOSubXact_RelationCache(bool isCommit, SubTransactionId mySubid, SubTrans
|
||||
* and enter it into the relcache.
|
||||
*/
|
||||
Relation RelationBuildLocalRelation(const char* relname, Oid relnamespace, TupleDesc tupDesc, Oid relid,
|
||||
Oid relfilenode, Oid reltablespace, bool shared_relation, bool mapped_relation, char relpersistence, char relkind,
|
||||
int8 row_compress, TableAmType tam_type, int8 relindexsplit, StorageType storage_type)
|
||||
Oid relfilenode, Oid reltablespace, bool shared_relation, bool mapped_relation, char relpersistence,
|
||||
char relkind, int8 row_compress, Datum reloptions, TableAmType tam_type, int8 relindexsplit,
|
||||
StorageType storage_type, Oid accessMethodObjectId)
|
||||
{
|
||||
Relation rel;
|
||||
MemoryContext oldcxt;
|
||||
@ -4452,6 +4459,7 @@ Relation RelationBuildLocalRelation(const char* relname, Oid relnamespace, Tuple
|
||||
rel->rd_rel->relowner = BOOTSTRAP_SUPERUSERID;
|
||||
rel->rd_rel->parttype = PARTTYPE_NON_PARTITIONED_RELATION;
|
||||
rel->rd_rel->relrowmovement = false;
|
||||
rel->rd_rel->relam = accessMethodObjectId;
|
||||
|
||||
/* set up persistence and relcache fields dependent on it */
|
||||
rel->rd_rel->relpersistence = relpersistence;
|
||||
@ -4508,6 +4516,13 @@ Relation RelationBuildLocalRelation(const char* relname, Oid relnamespace, Tuple
|
||||
|
||||
RelationInitPhysicalAddr(rel);
|
||||
|
||||
/* compressed option was set by RelationInitPhysicalAddr if rel->rd_options != NULL */
|
||||
if (rel->rd_options == NULL && reloptions && SUPPORT_COMPRESSED(relkind, rel->rd_rel->relam)) {
|
||||
StdRdOptions *options = (StdRdOptions *) default_reloptions(reloptions, false, RELOPT_KIND_HEAP);
|
||||
SetupPageCompressForRelation(&rel->rd_node, &options->compress, RelationGetRelationName(rel));
|
||||
}
|
||||
|
||||
|
||||
/* materialized view not initially scannable */
|
||||
if (relkind == RELKIND_MATVIEW)
|
||||
rel->rd_isscannable = false;
|
||||
@ -8106,6 +8121,45 @@ void GetTdeInfoFromRel(Relation rel, TdeInfo *tde_info)
|
||||
}
|
||||
}
|
||||
|
||||
void SetupPageCompressForRelation(RelFileNode* node, PageCompressOpts* compress_options, const char* relationName)
|
||||
{
|
||||
uint1 algorithm = compress_options->compressType;
|
||||
if (algorithm == COMPRESS_TYPE_NONE) {
|
||||
node->opt = 0;
|
||||
} else {
|
||||
if (!SUPPORT_PAGE_COMPRESSION) {
|
||||
ereport(ERROR, (errmsg("unsupported page compression on this platform")));
|
||||
}
|
||||
|
||||
uint1 compressLevel;
|
||||
bool symbol = false;
|
||||
if (compress_options->compressLevel >= 0) {
|
||||
symbol = true;
|
||||
compressLevel = compress_options->compressLevel;
|
||||
} else {
|
||||
symbol = false;
|
||||
compressLevel = -compress_options->compressLevel;
|
||||
}
|
||||
bool success = false;
|
||||
uint1 chunkSize = ConvertChunkSize(compress_options->compressChunkSize, &success);
|
||||
if (!success) {
|
||||
ereport(ERROR, (errmsg("invalid compress_chunk_size %d , must be one of %d, %d, %d or %d for %s",
|
||||
compress_options->compressChunkSize, BLCKSZ / 16, BLCKSZ / 8, BLCKSZ / 4, BLCKSZ / 2,
|
||||
relationName)));
|
||||
}
|
||||
uint1 preallocChunks;
|
||||
if (compress_options->compressPreallocChunks >= BLCKSZ / compress_options->compressChunkSize) {
|
||||
ereport(ERROR, (errmsg("invalid compress_prealloc_chunks %d , must be less than %d for %s",
|
||||
compress_options->compressPreallocChunks,
|
||||
BLCKSZ / compress_options->compressChunkSize, relationName)));
|
||||
} else {
|
||||
preallocChunks = (uint1)(compress_options->compressPreallocChunks);
|
||||
}
|
||||
node->opt = 0;
|
||||
SET_COMPRESS_OPTION((*node), compress_options->compressByteConvert, compress_options->compressDiffConvert,
|
||||
preallocChunks, symbol, compressLevel, algorithm, chunkSize);
|
||||
}
|
||||
}
|
||||
char RelationGetRelReplident(Relation r)
|
||||
{
|
||||
bool isNull = false;
|
||||
|
||||
Reference in New Issue
Block a user