Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3838074

Browse files
committed
Be more aggressive in avoiding tuple conversion.
According to the comments in tupconvert.c, it's necessary to performtuple conversion when either table has OIDs, and this was previouslychecked by ensuring that the tdtypeid value matched between the tablesin question. However, that's overly stringent: we have access totdhasoid and can test directly whether OIDs are present, which lets usavoid conversion in cases where the type OIDs are different but thetuple descriptors are entirely the same (and neither has OIDs). Thisis useful to the partitioning code, which can thereby avoid convertingtuples when inserting into a partition whose columns appear in thesame order as the parent columns, the normal case. It's possiblefor the tuple routing code to avoid some additional overhead in thiscase as well, so do that, too.It's not clear whether it would be OK to skip this when both tableshave OIDs: do callers count on this to build a new tuple (losing theprevious OID) in such instances? Until we figure it out, leave thebehavior in that case alone.Amit Langote, reviewed by me.
1 parent7fa7bf1 commit3838074

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

‎src/backend/access/common/tupconvert.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,13 @@ convert_tuples_by_position(TupleDesc indesc,
138138
nincols,noutcols)));
139139

140140
/*
141-
* Check to see if the map is one-to-one and the tuple types are the same.
142-
* (We check the latter because if they're not, we want to do conversion
143-
* to inject the right OID into the tuple datum.)
141+
* Check to see if the map is one-to-one, in which case we need not do
142+
* the tuple conversion. That's not enough though if either source or
143+
* destination (tuples) contains OIDs; we'd need conversion in that case
144+
* to inject the right OID into the tuple datum.
144145
*/
145146
if (indesc->natts==outdesc->natts&&
146-
indesc->tdtypeid==outdesc->tdtypeid)
147+
!indesc->tdhasoid&& !outdesc->tdhasoid)
147148
{
148149
for (i=0;i<n;i++)
149150
{
@@ -214,12 +215,13 @@ convert_tuples_by_name(TupleDesc indesc,
214215
attrMap=convert_tuples_by_name_map(indesc,outdesc,msg);
215216

216217
/*
217-
* Check to see if the map is one-to-one and the tuple types are the same.
218-
* (We check the latter because if they're not, we want to do conversion
219-
* to inject the right OID into the tuple datum.)
218+
* Check to see if the map is one-to-one, in which case we need not do
219+
* the tuple conversion. That's not enough though if either source or
220+
* destination (tuples) contains OIDs; we'd need conversion in that case
221+
* to inject the right OID into the tuple datum.
220222
*/
221223
if (indesc->natts==outdesc->natts&&
222-
indesc->tdtypeid==outdesc->tdtypeid)
224+
!indesc->tdhasoid&& !outdesc->tdhasoid)
223225
{
224226
same= true;
225227
for (i=0;i<n;i++)

‎src/backend/catalog/partition.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,12 +1700,11 @@ get_partition_for_tuple(PartitionDispatch *pd,
17001700
return-1;
17011701
}
17021702

1703-
if (myslot!=NULL)
1703+
if (myslot!=NULL&&map!=NULL)
17041704
{
17051705
HeapTupletuple=ExecFetchSlotTuple(slot);
17061706

17071707
ExecClearTuple(myslot);
1708-
Assert(map!=NULL);
17091708
tuple=do_convert_tuple(tuple,map);
17101709
ExecStoreTuple(tuple,myslot,InvalidBuffer, true);
17111710
slot=myslot;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp