summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2009-08-17 20:34:31 +0000
committerTom Lane2009-08-17 20:34:31 +0000
commit3fecffccfdbf8ac692da4e6264e8779962fffc7b (patch)
treeaac71ad4d85f31f5720866f12d5e6ea9704013ed
parentcec33141f6f85ffaf901fe6b7ebbdb50b0b1bc74 (diff)
Department of marginal improvements: teach tupconvert.c to avoid doing a
physical conversion when there are dropped columns in the same places in the input and output tupdescs. This avoids possible performance loss from the recent patch to improve dropped-column handling, in some cases where the old code would have worked.
-rw-r--r--src/backend/access/common/tupconvert.c42
1 files changed, 32 insertions, 10 deletions
diff --git a/src/backend/access/common/tupconvert.c b/src/backend/access/common/tupconvert.c
index b7da973488..5364951992 100644
--- a/src/backend/access/common/tupconvert.c
+++ b/src/backend/access/common/tupconvert.c
@@ -146,11 +146,22 @@ convert_tuples_by_position(TupleDesc indesc,
{
for (i = 0; i < n; i++)
{
- if (attrMap[i] != (i+1))
- {
- same = false;
- break;
- }
+ if (attrMap[i] == (i+1))
+ continue;
+
+ /*
+ * If it's a dropped column and the corresponding input
+ * column is also dropped, we needn't convert. However,
+ * attlen and attalign must agree.
+ */
+ if (attrMap[i] == 0 &&
+ indesc->attrs[i]->attisdropped &&
+ indesc->attrs[i]->attlen == outdesc->attrs[i]->attlen &&
+ indesc->attrs[i]->attalign == outdesc->attrs[i]->attalign)
+ continue;
+
+ same = false;
+ break;
}
}
else
@@ -255,11 +266,22 @@ convert_tuples_by_name(TupleDesc indesc,
same = true;
for (i = 0; i < n; i++)
{
- if (attrMap[i] != (i+1))
- {
- same = false;
- break;
- }
+ if (attrMap[i] == (i+1))
+ continue;
+
+ /*
+ * If it's a dropped column and the corresponding input
+ * column is also dropped, we needn't convert. However,
+ * attlen and attalign must agree.
+ */
+ if (attrMap[i] == 0 &&
+ indesc->attrs[i]->attisdropped &&
+ indesc->attrs[i]->attlen == outdesc->attrs[i]->attlen &&
+ indesc->attrs[i]->attalign == outdesc->attrs[i]->attalign)
+ continue;
+
+ same = false;
+ break;
}
}
else