@ -338,6 +338,16 @@ static void SpecialWorkOfRelationLocInfo(Relation rel)
|
|||||||
|
|
||||||
static void SpecialWorkForLocalRel(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)) {
|
if (RelationIsIndex(rel)) {
|
||||||
rel->rd_aminfo = (RelationAmInfo *)MemoryContextAllocZero(rel->rd_indexcxt, sizeof(RelationAmInfo));
|
rel->rd_aminfo = (RelationAmInfo *)MemoryContextAllocZero(rel->rd_indexcxt, sizeof(RelationAmInfo));
|
||||||
}
|
}
|
||||||
|
@ -62,8 +62,6 @@
|
|||||||
#include "utils/datum.h"
|
#include "utils/datum.h"
|
||||||
#include "utils/knl_relcache.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 uint32 PartKeyHashFunc(const void *key, Size keysize);
|
||||||
static int PartKeyMatchFunc(const void *key1, const void *key2, 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->listElementsNum = src_lpm->listElementsNum;
|
||||||
dst_lpm->listElements = CopyListElements(src_lpm->listElements, 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;
|
return dst_lpm;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1726,7 +1717,7 @@ static int PartKeyMatchFunc(const void *key1, const void *key2, Size keysize)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HTAB *BuildPartKeyHashTable(ListPartitionMap *listMap)
|
HTAB *BuildPartKeyHashTable(ListPartitionMap *listMap)
|
||||||
{
|
{
|
||||||
HASHCTL hashCtl;
|
HASHCTL hashCtl;
|
||||||
errno_t rc;
|
errno_t rc;
|
||||||
@ -1742,8 +1733,10 @@ static HTAB *BuildPartKeyHashTable(ListPartitionMap *listMap)
|
|||||||
hashCtl.entrysize = sizeof(PartElementHashEntry);
|
hashCtl.entrysize = sizeof(PartElementHashEntry);
|
||||||
hashCtl.hash = PartKeyHashFunc;
|
hashCtl.hash = PartKeyHashFunc;
|
||||||
hashCtl.match = PartKeyMatchFunc;
|
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;
|
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);
|
Assert (listMap != NULL && partElem != NULL);
|
||||||
|
|
||||||
|
@ -1208,11 +1208,6 @@ static void ExecHashIncreaseNumBuckets(HashJoinTable hashtable)
|
|||||||
idx += MAXALIGN(HJTUPLE_OVERHEAD + HJTUPLE_MINTUPLE(hashTuple)->t_len);
|
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1240,7 +1240,7 @@ restart:
|
|||||||
*/
|
*/
|
||||||
innerTupleSlot = GetNextBatchTuple<INNER_VAR>(node);
|
innerTupleSlot = GetNextBatchTuple<INNER_VAR>(node);
|
||||||
node->mj_InnerOffset = innerTupleSlot;
|
node->mj_InnerOffset = innerTupleSlot;
|
||||||
MJ_DEBUG_PROC_NODE(innerTupleSlot);
|
VEC_MJ_DEBUG_PROC_NODE(innerTupleSlot);
|
||||||
node->mj_MatchedInner = false;
|
node->mj_MatchedInner = false;
|
||||||
|
|
||||||
/* Compute join values and check for unmatchability */
|
/* Compute join values and check for unmatchability */
|
||||||
@ -1326,7 +1326,7 @@ restart:
|
|||||||
*/
|
*/
|
||||||
outerTupleSlot = GetNextBatchTuple<OUTER_VAR>(node);
|
outerTupleSlot = GetNextBatchTuple<OUTER_VAR>(node);
|
||||||
node->mj_OuterOffset = outerTupleSlot;
|
node->mj_OuterOffset = outerTupleSlot;
|
||||||
MJ_DEBUG_PROC_NODE(outerTupleSlot);
|
VEC_MJ_DEBUG_PROC_NODE(outerTupleSlot);
|
||||||
node->mj_MatchedOuter = false;
|
node->mj_MatchedOuter = false;
|
||||||
/* Compute join values and check for unmatchability */
|
/* Compute join values and check for unmatchability */
|
||||||
switch (MJGetOuterValues(node, outerTupleSlot)) {
|
switch (MJGetOuterValues(node, outerTupleSlot)) {
|
||||||
@ -1553,7 +1553,7 @@ restart:
|
|||||||
*/
|
*/
|
||||||
outerTupleSlot = GetNextBatchTuple<OUTER_VAR>(node);
|
outerTupleSlot = GetNextBatchTuple<OUTER_VAR>(node);
|
||||||
node->mj_OuterOffset = outerTupleSlot;
|
node->mj_OuterOffset = outerTupleSlot;
|
||||||
MJ_DEBUG_PROC_NODE(outerTupleSlot);
|
VEC_MJ_DEBUG_PROC_NODE(outerTupleSlot);
|
||||||
node->mj_MatchedOuter = false;
|
node->mj_MatchedOuter = false;
|
||||||
|
|
||||||
/* Compute join values and check for unmatchability */
|
/* Compute join values and check for unmatchability */
|
||||||
@ -1607,7 +1607,7 @@ restart:
|
|||||||
*/
|
*/
|
||||||
innerTupleSlot = GetNextBatchTuple<INNER_VAR>(node);
|
innerTupleSlot = GetNextBatchTuple<INNER_VAR>(node);
|
||||||
node->mj_InnerOffset = innerTupleSlot;
|
node->mj_InnerOffset = innerTupleSlot;
|
||||||
MJ_DEBUG_PROC_NODE(innerTupleSlot);
|
VEC_MJ_DEBUG_PROC_NODE(innerTupleSlot);
|
||||||
node->mj_MatchedInner = false;
|
node->mj_MatchedInner = false;
|
||||||
/* Compute join values and check for unmatchability */
|
/* Compute join values and check for unmatchability */
|
||||||
switch (MJGetInnerValues(node, innerTupleSlot)) {
|
switch (MJGetInnerValues(node, innerTupleSlot)) {
|
||||||
@ -1663,7 +1663,7 @@ restart:
|
|||||||
*/
|
*/
|
||||||
innerTupleSlot = GetNextBatchTuple<INNER_VAR>(node);
|
innerTupleSlot = GetNextBatchTuple<INNER_VAR>(node);
|
||||||
node->mj_InnerOffset = innerTupleSlot;
|
node->mj_InnerOffset = innerTupleSlot;
|
||||||
MJ_DEBUG_PROC_NODE(innerTupleSlot);
|
VEC_MJ_DEBUG_PROC_NODE(innerTupleSlot);
|
||||||
node->mj_MatchedInner = false;
|
node->mj_MatchedInner = false;
|
||||||
if (BatchTupleIsNull(innerTupleSlot)) {
|
if (BatchTupleIsNull(innerTupleSlot)) {
|
||||||
MJ_printf("ExecMergeJoin: end of inner subplan\n");
|
MJ_printf("ExecMergeJoin: end of inner subplan\n");
|
||||||
@ -1694,7 +1694,7 @@ restart:
|
|||||||
*/
|
*/
|
||||||
outerTupleSlot = GetNextBatchTuple<OUTER_VAR>(node);
|
outerTupleSlot = GetNextBatchTuple<OUTER_VAR>(node);
|
||||||
node->mj_OuterOffset = outerTupleSlot;
|
node->mj_OuterOffset = outerTupleSlot;
|
||||||
MJ_DEBUG_PROC_NODE(outerTupleSlot);
|
VEC_MJ_DEBUG_PROC_NODE(outerTupleSlot);
|
||||||
node->mj_MatchedOuter = false;
|
node->mj_MatchedOuter = false;
|
||||||
if (BatchTupleIsNull(outerTupleSlot)) {
|
if (BatchTupleIsNull(outerTupleSlot)) {
|
||||||
MJ_printf("ExecMergeJoin: end of outer subplan\n");
|
MJ_printf("ExecMergeJoin: end of outer subplan\n");
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#ifndef EXECDEBUG_H
|
#ifndef EXECDEBUG_H
|
||||||
#define EXECDEBUG_H
|
#define EXECDEBUG_H
|
||||||
|
|
||||||
|
#include "access/printtup.h"
|
||||||
#include "executor/executor.h"
|
#include "executor/executor.h"
|
||||||
#include "nodes/print.h"
|
#include "nodes/print.h"
|
||||||
|
|
||||||
@ -118,7 +119,6 @@
|
|||||||
* ----------------
|
* ----------------
|
||||||
*/
|
*/
|
||||||
#ifdef EXEC_MERGEJOINDEBUG
|
#ifdef EXEC_MERGEJOINDEBUG
|
||||||
|
|
||||||
#define MJ_nodeDisplay(l) nodeDisplay(l)
|
#define MJ_nodeDisplay(l) nodeDisplay(l)
|
||||||
#define MJ_printf(s) printf(s)
|
#define MJ_printf(s) printf(s)
|
||||||
#define MJ1_printf(s, p) printf(s, p)
|
#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_QUAL(clause, res) MJ2_printf(" ExecQual(%s, econtext) returns %s\n", CppAsString(clause), T_OR_F(res))
|
||||||
#define MJ_DEBUG_PROC_NODE(slot) \
|
#define MJ_DEBUG_PROC_NODE(slot) \
|
||||||
MJ2_printf(" %s = ExecProcNode(...) returns %s\n", CppAsString(slot), NULL_OR_TUPLE(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
|
#else
|
||||||
|
|
||||||
#define MJ_nodeDisplay(l)
|
#define MJ_nodeDisplay(l)
|
||||||
@ -140,6 +144,8 @@
|
|||||||
#define MJ_DEBUG_COMPARE(res)
|
#define MJ_DEBUG_COMPARE(res)
|
||||||
#define MJ_DEBUG_QUAL(clause, res)
|
#define MJ_DEBUG_QUAL(clause, res)
|
||||||
#define MJ_DEBUG_PROC_NODE(slot)
|
#define MJ_DEBUG_PROC_NODE(slot)
|
||||||
|
#define VEC_NULL_OR_TUPLE(slot)
|
||||||
|
#define VEC_MJ_DEBUG_PROC_NODE(slot)
|
||||||
#endif /* EXEC_MERGEJOINDEBUG */
|
#endif /* EXEC_MERGEJOINDEBUG */
|
||||||
|
|
||||||
#endif /* ExecDebugIncluded */
|
#endif /* ExecDebugIncluded */
|
||||||
|
@ -159,6 +159,8 @@ typedef struct HashPartitionMap {
|
|||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
extern void InsertPartKeyHashTable(ListPartitionMap *listMap, ListPartElement *partElem, int partSeqNo);
|
||||||
|
extern HTAB *BuildPartKeyHashTable(ListPartitionMap *listMap);
|
||||||
extern bool IsDefaultValueListPartition(ListPartitionMap *listMap, ListPartElement *partElem);
|
extern bool IsDefaultValueListPartition(ListPartitionMap *listMap, ListPartElement *partElem);
|
||||||
char *PartKeyGetCstring(PartitionKey* partkeys);
|
char *PartKeyGetCstring(PartitionKey* partkeys);
|
||||||
extern bool ConstEqual(Const *c1, Const *c2);
|
extern bool ConstEqual(Const *c1, Const *c2);
|
||||||
|
Reference in New Issue
Block a user