mirror of https://github.com/citusdata/citus.git
Move check into TargetShardIntervalForFastPathQuery
parent
026db60075
commit
d4352646b9
|
@ -156,7 +156,8 @@ static int CompareInsertValuesByShardId(const void *leftElement,
|
||||||
static uint64 GetAnchorShardId(List *relationShardList);
|
static uint64 GetAnchorShardId(List *relationShardList);
|
||||||
static List * TargetShardIntervalForFastPathQuery(Query *query,
|
static List * TargetShardIntervalForFastPathQuery(Query *query,
|
||||||
Const **partitionValueConst,
|
Const **partitionValueConst,
|
||||||
bool *isMultiShardQuery);
|
bool *isMultiShardQuery,
|
||||||
|
Const *distributionKeyValue);
|
||||||
static List * SingleShardSelectTaskList(Query *query, uint64 jobId,
|
static List * SingleShardSelectTaskList(Query *query, uint64 jobId,
|
||||||
List *relationShardList, List *placementList,
|
List *relationShardList, List *placementList,
|
||||||
uint64 shardId);
|
uint64 shardId);
|
||||||
|
@ -2043,31 +2044,12 @@ PlanRouterQuery(Query *originalQuery,
|
||||||
*/
|
*/
|
||||||
if (fastPathRouterQuery)
|
if (fastPathRouterQuery)
|
||||||
{
|
{
|
||||||
List *shardIntervalList = NIL;
|
|
||||||
Const *distributionKeyValue =
|
Const *distributionKeyValue =
|
||||||
plannerRestrictionContext->fastPathRestrictionContext->distributionKeyValue;
|
plannerRestrictionContext->fastPathRestrictionContext->distributionKeyValue;
|
||||||
|
|
||||||
if (distributionKeyValue)
|
List *shardIntervalList =
|
||||||
{
|
|
||||||
Oid relationId = ExtractFirstDistributedTableId(originalQuery);
|
|
||||||
DistTableCacheEntry *cache = DistributedTableCacheEntry(relationId);
|
|
||||||
ShardInterval *shardInterval =
|
|
||||||
FindShardInterval(distributionKeyValue->constvalue, cache);
|
|
||||||
|
|
||||||
shardIntervalList = list_make1(shardInterval);
|
|
||||||
|
|
||||||
if (partitionValueConst != NULL)
|
|
||||||
{
|
|
||||||
/* set the outgoing partition column value if requested */
|
|
||||||
*partitionValueConst = distributionKeyValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
shardIntervalList =
|
|
||||||
TargetShardIntervalForFastPathQuery(originalQuery, partitionValueConst,
|
TargetShardIntervalForFastPathQuery(originalQuery, partitionValueConst,
|
||||||
&isMultiShardQuery);
|
&isMultiShardQuery, distributionKeyValue);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2289,15 +2271,27 @@ GetAnchorShardId(List *prunedShardIntervalListList)
|
||||||
*/
|
*/
|
||||||
static List *
|
static List *
|
||||||
TargetShardIntervalForFastPathQuery(Query *query, Const **partitionValueConst,
|
TargetShardIntervalForFastPathQuery(Query *query, Const **partitionValueConst,
|
||||||
bool *isMultiShardQuery)
|
bool *isMultiShardQuery, Const *distributionKeyValue)
|
||||||
{
|
{
|
||||||
Const *queryPartitionValueConst = NULL;
|
|
||||||
|
|
||||||
Oid relationId = ExtractFirstDistributedTableId(query);
|
Oid relationId = ExtractFirstDistributedTableId(query);
|
||||||
|
|
||||||
|
if (distributionKeyValue)
|
||||||
|
{
|
||||||
|
DistTableCacheEntry *cache = DistributedTableCacheEntry(relationId);
|
||||||
|
ShardInterval *shardInterval =
|
||||||
|
FindShardInterval(distributionKeyValue->constvalue, cache);
|
||||||
|
|
||||||
|
if (partitionValueConst != NULL)
|
||||||
|
{
|
||||||
|
/* set the outgoing partition column value if requested */
|
||||||
|
*partitionValueConst = distributionKeyValue;
|
||||||
|
}
|
||||||
|
return list_make1(shardInterval);
|
||||||
|
}
|
||||||
|
|
||||||
Node *quals = query->jointree->quals;
|
Node *quals = query->jointree->quals;
|
||||||
|
|
||||||
int relationIndex = 1;
|
int relationIndex = 1;
|
||||||
|
Const *queryPartitionValueConst = NULL;
|
||||||
List *prunedShardIntervalList =
|
List *prunedShardIntervalList =
|
||||||
PruneShards(relationId, relationIndex, make_ands_implicit((Expr *) quals),
|
PruneShards(relationId, relationIndex, make_ands_implicit((Expr *) quals),
|
||||||
&queryPartitionValueConst);
|
&queryPartitionValueConst);
|
||||||
|
|
Loading…
Reference in New Issue