未验证 提交 e12d8cab 编写于 作者: Z Zhenghua Lyu 提交者: GitHub

Do not generate ReshuffleExpr for replicated table

When we expand a partial replicated table via `alter
table t expand table`, internally we use the split-update
framework to implement the expansion. That framework is
designed for hash-distribtued tables at first. For replicated
table, we do not need the reshuffle_expr(filter condition) at
all because we need to transfer all data in a replicated table.
上级 5583ecde
......@@ -14453,7 +14453,7 @@ ReshuffleRelationData(Relation rel)
char *namespace_name;
RangeVar *relation;
UpdateStmt *stmt = makeNode(UpdateStmt);
ReshuffleExpr *reshuffleExpr = makeNode(ReshuffleExpr);
ReshuffleExpr *reshuffleExpr = NULL;
GpPolicy *policy = rel->rd_cdbpolicy;
int i;
Query *q;
......@@ -14485,9 +14485,13 @@ ReshuffleRelationData(Relation rel)
stmt->relation = relation;
/* make an reshuffle expression to filter some tuples */
reshuffleExpr->newSegs = getgpsegmentCount();
reshuffleExpr->oldSegs = policy->numsegments;
reshuffleExpr->ptype = policy->ptype;
if (!GpPolicyIsReplicated(policy))
{
reshuffleExpr = makeNode(ReshuffleExpr);
reshuffleExpr->newSegs = getgpsegmentCount();
reshuffleExpr->oldSegs = policy->numsegments;
reshuffleExpr->ptype = policy->ptype;
}
stmt->whereClause = (Node*)reshuffleExpr;
/* make an target list for the UpdateStmt */
......
......@@ -5212,6 +5212,7 @@ ExecEvalReshuffleExpr(ReshuffleExprState *astate,
bool result;
Assert(!IS_QUERY_DISPATCHER());
Assert(sr->ptype != POLICYTYPE_REPLICATED);
if(sr->ptype == POLICYTYPE_PARTITIONED)
{
......@@ -5252,26 +5253,6 @@ ExecEvalReshuffleExpr(ReshuffleExprState *astate,
result = (cdbhashrandomseg(newSegs) >= sr->oldSegs);
}
}
else if(sr->ptype == POLICYTYPE_REPLICATED)
{
/*
* For replicated tables:
* if we have 3 old segments: 0 1 2
* and we add 4 new segments: 3 4 5 6
* The seg#0 is responsible for reshuffling data into seg#3 and seg#6
* The seg#1 is responsible for reshuffling data into seg#4
* The seg#2 is responsible for reshuffling data into seg#5
*
* 1. New segments need not reshuffle data
* 2. if we have 3 old segments and only add 1 new segments,
* then the seg#1 and seg#2 need not reshuffle data
*/
if (GpIdentity.segindex >= sr->oldSegs ||
GpIdentity.segindex + sr->oldSegs >= sr->newSegs)
result = false;
else
result = true;
}
else
result = false;
......
......@@ -97,7 +97,8 @@
* For replicated table, the table data is same in the all old
* segments, so there do not need to delete any tuples, it only
* need copy the tuple which is in the old segments to the new
* segments, so the ReshuffleExpr do not filte any tuples, In
* segments, the ReshuffleExpr do not filte any tuples, and
* we make it NULL pointer in the Parse Tree as an optimization,
* the Reshuffle node, we neglect the tuple which is generated
* for deleting, only return the inserting tuple to motion. Let
* me illustrate this with an example:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册