From 93e3afc25c425a3d6ea7cdd67eeafb48a4299629 Mon Sep 17 00:00:00 2001 From: Jason Petersen Date: Thu, 27 Apr 2017 13:15:48 -0600 Subject: [PATCH] Remove FastShardPruning method With the other simplifications, it doesn't make sense to keep around. --- .../planner/multi_router_planner.c | 27 +++---------------- src/backend/distributed/utils/node_metadata.c | 3 ++- .../distributed/multi_router_planner.h | 1 - 3 files changed, 5 insertions(+), 26 deletions(-) diff --git a/src/backend/distributed/planner/multi_router_planner.c b/src/backend/distributed/planner/multi_router_planner.c index 7cfbc8efc..2829ecdcc 100644 --- a/src/backend/distributed/planner/multi_router_planner.c +++ b/src/backend/distributed/planner/multi_router_planner.c @@ -1974,8 +1974,9 @@ FindShardForInsert(Query *query, DeferredErrorMessage **planningError) if (partitionMethod == DISTRIBUTE_BY_HASH || partitionMethod == DISTRIBUTE_BY_RANGE) { Datum partitionValue = partitionValueConst->constvalue; - ShardInterval *shardInterval = FastShardPruning(distributedTableId, - partitionValue); + DistTableCacheEntry *cacheEntry = DistributedTableCacheEntry(distributedTableId); + ShardInterval *shardInterval = FindShardInterval(partitionValue, cacheEntry); + if (shardInterval != NULL) { prunedShardList = list_make1(shardInterval); @@ -2047,28 +2048,6 @@ FindShardForInsert(Query *query, DeferredErrorMessage **planningError) } -/* - * FastShardPruning is a higher level API for FindShardInterval function. Given the - * relationId of the distributed table and partitionValue, FastShardPruning function finds - * the corresponding shard interval that the partitionValue should be in. FastShardPruning - * returns NULL if no ShardIntervals exist for the given partitionValue. - */ -ShardInterval * -FastShardPruning(Oid distributedTableId, Datum partitionValue) -{ - DistTableCacheEntry *cacheEntry = DistributedTableCacheEntry(distributedTableId); - ShardInterval *shardInterval = NULL; - - /* - * Call FindShardInterval to find the corresponding shard interval for the - * given partition value. - */ - shardInterval = FindShardInterval(partitionValue, cacheEntry); - - return shardInterval; -} - - /* * FindShardForUpdateOrDelete finds the shard interval in which an UPDATE or * DELETE command should be applied, or sets planningError when the query diff --git a/src/backend/distributed/utils/node_metadata.c b/src/backend/distributed/utils/node_metadata.c index aa16e1502..fd4d8970b 100644 --- a/src/backend/distributed/utils/node_metadata.c +++ b/src/backend/distributed/utils/node_metadata.c @@ -332,6 +332,7 @@ get_shard_id_for_distribution_column(PG_FUNCTION_ARGS) char *distributionValueString = NULL; Datum inputDatum = 0; Datum distributionValueDatum = 0; + DistTableCacheEntry *cacheEntry = DistributedTableCacheEntry(relationId); /* if given table is not reference table, distributionValue cannot be NULL */ if (PG_ARGISNULL(1)) @@ -351,7 +352,7 @@ get_shard_id_for_distribution_column(PG_FUNCTION_ARGS) distributionValueDatum = StringToDatum(distributionValueString, distributionDataType); - shardInterval = FastShardPruning(relationId, distributionValueDatum); + shardInterval = FindShardInterval(distributionValueDatum, cacheEntry); } else { diff --git a/src/include/distributed/multi_router_planner.h b/src/include/distributed/multi_router_planner.h index 322cbf791..589724464 100644 --- a/src/include/distributed/multi_router_planner.h +++ b/src/include/distributed/multi_router_planner.h @@ -44,7 +44,6 @@ extern void AddShardIntervalRestrictionToSelect(Query *subqery, ShardInterval *shardInterval); extern ShardInterval * FindShardForInsert(Query *query, DeferredErrorMessage **planningError); -extern ShardInterval * FastShardPruning(Oid distributedTableId, Datum partitionValue); #endif /* MULTI_ROUTER_PLANNER_H */