diff --git a/src/common/backend/utils/cache/knl_localtabdefcache.cpp b/src/common/backend/utils/cache/knl_localtabdefcache.cpp index 46a59cb33..20c38d218 100644 --- a/src/common/backend/utils/cache/knl_localtabdefcache.cpp +++ b/src/common/backend/utils/cache/knl_localtabdefcache.cpp @@ -338,6 +338,16 @@ static void SpecialWorkOfRelationLocInfo(Relation rel) static void SpecialWorkForLocalRel(Relation rel) { + if (rel->partMap != NULL && rel->partMap->type == PART_TYPE_LIST) { + ListPartitionMap *rel_lpm = (ListPartitionMap *)rel->partMap; + /* copy part key hash-table */ + BuildPartKeyHashTable(rel_lpm); + for (int partSeq = 0; partSeq < rel_lpm->listElementsNum; partSeq++) { + ListPartElement *lpe = &(rel_lpm->listElements[partSeq]); + InsertPartKeyHashTable(rel_lpm, lpe, partSeq); + } + } + if (RelationIsIndex(rel)) { rel->rd_aminfo = (RelationAmInfo *)MemoryContextAllocZero(rel->rd_indexcxt, sizeof(RelationAmInfo)); } diff --git a/src/gausskernel/cbb/utils/partition/partitionmap.cpp b/src/gausskernel/cbb/utils/partition/partitionmap.cpp index f5221a9cc..257f1b2e8 100755 --- a/src/gausskernel/cbb/utils/partition/partitionmap.cpp +++ b/src/gausskernel/cbb/utils/partition/partitionmap.cpp @@ -62,8 +62,6 @@ #include "utils/datum.h" #include "utils/knl_relcache.h" -static void InsertPartKeyHashTable(ListPartitionMap *listMap, ListPartElement *partElem, int partSeqNo); -static HTAB *BuildPartKeyHashTable(ListPartitionMap *listMap); static uint32 PartKeyHashFunc(const void *key, Size keysize); static int PartKeyMatchFunc(const void *key1, const void *key2, Size keysize); @@ -1300,13 +1298,6 @@ ListPartitionMap *CopyListPartitionMap(ListPartitionMap *src_lpm) dst_lpm->listElementsNum = src_lpm->listElementsNum; dst_lpm->listElements = CopyListElements(src_lpm->listElements, src_lpm->listElementsNum); - /* copy part key hash-table */ - dst_lpm->ht = BuildPartKeyHashTable(dst_lpm); - for (int partSeq = 0; partSeq < dst_lpm->listElementsNum; partSeq++) { - ListPartElement *lpe = &(dst_lpm->listElements[partSeq]); - InsertPartKeyHashTable(dst_lpm, lpe, partSeq); - } - return dst_lpm; } @@ -1726,7 +1717,7 @@ static int PartKeyMatchFunc(const void *key1, const void *key2, Size keysize) return ret; } -static HTAB *BuildPartKeyHashTable(ListPartitionMap *listMap) +HTAB *BuildPartKeyHashTable(ListPartitionMap *listMap) { HASHCTL hashCtl; errno_t rc; @@ -1742,8 +1733,10 @@ static HTAB *BuildPartKeyHashTable(ListPartitionMap *listMap) hashCtl.entrysize = sizeof(PartElementHashEntry); hashCtl.hash = PartKeyHashFunc; hashCtl.match = PartKeyMatchFunc; - listMap->ht = hash_create(si.data, 1024L, &hashCtl, HASH_ELEM | HASH_FUNCTION | HASH_COMPARE); + hashCtl.hcxt = LocalMyDBCacheMemCxt(); + listMap->ht = hash_create(si.data, 1024L, &hashCtl, HASH_ELEM | HASH_FUNCTION | HASH_COMPARE | HASH_CONTEXT); + FreeStringInfo(&si); return listMap->ht; } @@ -1756,7 +1749,7 @@ static inline void DeepCopyPartKey(PartitionKey* src, PartitionKey* dst) } } -static void InsertPartKeyHashTable(ListPartitionMap *listMap, ListPartElement *partElem, int partSeqNo) +void InsertPartKeyHashTable(ListPartitionMap *listMap, ListPartElement *partElem, int partSeqNo) { Assert (listMap != NULL && partElem != NULL); diff --git a/src/gausskernel/runtime/executor/nodeHash.cpp b/src/gausskernel/runtime/executor/nodeHash.cpp index 3fd554da6..13e73d97b 100644 --- a/src/gausskernel/runtime/executor/nodeHash.cpp +++ b/src/gausskernel/runtime/executor/nodeHash.cpp @@ -1208,11 +1208,6 @@ static void ExecHashIncreaseNumBuckets(HashJoinTable hashtable) idx += MAXALIGN(HJTUPLE_OVERHEAD + HJTUPLE_MINTUPLE(hashTuple)->t_len); } } - -#ifdef HJDEBUG - printf("Nbuckets increased to %d, average items per bucket %.1f\n", hashtable->nbuckets, - batchTuples / hashtable->nbuckets); -#endif } /* diff --git a/src/gausskernel/runtime/vecexecutor/vecnode/vecmergejoin.cpp b/src/gausskernel/runtime/vecexecutor/vecnode/vecmergejoin.cpp index b3c20ea87..80b88911b 100644 --- a/src/gausskernel/runtime/vecexecutor/vecnode/vecmergejoin.cpp +++ b/src/gausskernel/runtime/vecexecutor/vecnode/vecmergejoin.cpp @@ -1240,7 +1240,7 @@ restart: */ innerTupleSlot = GetNextBatchTuple(node); node->mj_InnerOffset = innerTupleSlot; - MJ_DEBUG_PROC_NODE(innerTupleSlot); + VEC_MJ_DEBUG_PROC_NODE(innerTupleSlot); node->mj_MatchedInner = false; /* Compute join values and check for unmatchability */ @@ -1326,7 +1326,7 @@ restart: */ outerTupleSlot = GetNextBatchTuple(node); node->mj_OuterOffset = outerTupleSlot; - MJ_DEBUG_PROC_NODE(outerTupleSlot); + VEC_MJ_DEBUG_PROC_NODE(outerTupleSlot); node->mj_MatchedOuter = false; /* Compute join values and check for unmatchability */ switch (MJGetOuterValues(node, outerTupleSlot)) { @@ -1553,7 +1553,7 @@ restart: */ outerTupleSlot = GetNextBatchTuple(node); node->mj_OuterOffset = outerTupleSlot; - MJ_DEBUG_PROC_NODE(outerTupleSlot); + VEC_MJ_DEBUG_PROC_NODE(outerTupleSlot); node->mj_MatchedOuter = false; /* Compute join values and check for unmatchability */ @@ -1607,7 +1607,7 @@ restart: */ innerTupleSlot = GetNextBatchTuple(node); node->mj_InnerOffset = innerTupleSlot; - MJ_DEBUG_PROC_NODE(innerTupleSlot); + VEC_MJ_DEBUG_PROC_NODE(innerTupleSlot); node->mj_MatchedInner = false; /* Compute join values and check for unmatchability */ switch (MJGetInnerValues(node, innerTupleSlot)) { @@ -1663,7 +1663,7 @@ restart: */ innerTupleSlot = GetNextBatchTuple(node); node->mj_InnerOffset = innerTupleSlot; - MJ_DEBUG_PROC_NODE(innerTupleSlot); + VEC_MJ_DEBUG_PROC_NODE(innerTupleSlot); node->mj_MatchedInner = false; if (BatchTupleIsNull(innerTupleSlot)) { MJ_printf("ExecMergeJoin: end of inner subplan\n"); @@ -1694,7 +1694,7 @@ restart: */ outerTupleSlot = GetNextBatchTuple(node); node->mj_OuterOffset = outerTupleSlot; - MJ_DEBUG_PROC_NODE(outerTupleSlot); + VEC_MJ_DEBUG_PROC_NODE(outerTupleSlot); node->mj_MatchedOuter = false; if (BatchTupleIsNull(outerTupleSlot)) { MJ_printf("ExecMergeJoin: end of outer subplan\n"); diff --git a/src/include/executor/exec/execdebug.h b/src/include/executor/exec/execdebug.h index b30e6a894..82896388f 100644 --- a/src/include/executor/exec/execdebug.h +++ b/src/include/executor/exec/execdebug.h @@ -17,6 +17,7 @@ #ifndef EXECDEBUG_H #define EXECDEBUG_H +#include "access/printtup.h" #include "executor/executor.h" #include "nodes/print.h" @@ -118,7 +119,6 @@ * ---------------- */ #ifdef EXEC_MERGEJOINDEBUG - #define MJ_nodeDisplay(l) nodeDisplay(l) #define MJ_printf(s) printf(s) #define MJ1_printf(s, p) printf(s, p) @@ -129,6 +129,10 @@ #define MJ_DEBUG_QUAL(clause, res) MJ2_printf(" ExecQual(%s, econtext) returns %s\n", CppAsString(clause), T_OR_F(res)) #define MJ_DEBUG_PROC_NODE(slot) \ MJ2_printf(" %s = ExecProcNode(...) returns %s\n", CppAsString(slot), NULL_OR_TUPLE(slot)) +/* merge join vector */ +#define VEC_NULL_OR_TUPLE(slot) ((slot.m_fEmpty) ? "null" : "a tuple") +#define VEC_MJ_DEBUG_PROC_NODE(slot) \ + MJ2_printf(" %s = ExecProcNode(...) returns %s\n", CppAsString(slot), VEC_NULL_OR_TUPLE(slot)) #else #define MJ_nodeDisplay(l) @@ -140,6 +144,8 @@ #define MJ_DEBUG_COMPARE(res) #define MJ_DEBUG_QUAL(clause, res) #define MJ_DEBUG_PROC_NODE(slot) +#define VEC_NULL_OR_TUPLE(slot) +#define VEC_MJ_DEBUG_PROC_NODE(slot) #endif /* EXEC_MERGEJOINDEBUG */ #endif /* ExecDebugIncluded */ diff --git a/src/include/utils/partitionmap_gs.h b/src/include/utils/partitionmap_gs.h index f8077c16d..637b27fcf 100755 --- a/src/include/utils/partitionmap_gs.h +++ b/src/include/utils/partitionmap_gs.h @@ -159,6 +159,8 @@ typedef struct HashPartitionMap { } \ } while (0) +extern void InsertPartKeyHashTable(ListPartitionMap *listMap, ListPartElement *partElem, int partSeqNo); +extern HTAB *BuildPartKeyHashTable(ListPartitionMap *listMap); extern bool IsDefaultValueListPartition(ListPartitionMap *listMap, ListPartElement *partElem); char *PartKeyGetCstring(PartitionKey* partkeys); extern bool ConstEqual(Const *c1, Const *c2);