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

Commit7c57449

Browse files
committed
Avoid O(N^2) behavior when enlarging SPI tuple table in spi_printtup().
For no obvious reason, spi_printtup() was coded to enlarge the tuplepointer table by just 256 slots at a time, rather than doubling the size ateach reallocation, as is our usual habit. For very large SPI results, thismakes for O(N^2) time spent in repalloc(), which of course soon comes todominate the runtime. Use the standard doubling approach instead.This is a longstanding performance bug, so back-patch to all activebranches.Neil Conway
1 parente41718f commit7c57449

File tree

1 file changed

+2
-1
lines changed
  • src/backend/executor

1 file changed

+2
-1
lines changed

‎src/backend/executor/spi.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1622,7 +1622,8 @@ spi_printtup(TupleTableSlot *slot, DestReceiver *self)
16221622

16231623
if (tuptable->free==0)
16241624
{
1625-
tuptable->free=256;
1625+
/* Double the size of the pointer array */
1626+
tuptable->free=tuptable->alloced;
16261627
tuptable->alloced+=tuptable->free;
16271628
tuptable->vals= (HeapTuple*)repalloc(tuptable->vals,
16281629
tuptable->alloced*sizeof(HeapTuple));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp