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

Commit68a14ca

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 parent93fcb4a commit68a14ca

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
@@ -1797,7 +1797,8 @@ spi_printtup(TupleTableSlot *slot, DestReceiver *self)
17971797

17981798
if (tuptable->free==0)
17991799
{
1800-
tuptable->free=256;
1800+
/* Double the size of the pointer array */
1801+
tuptable->free=tuptable->alloced;
18011802
tuptable->alloced+=tuptable->free;
18021803
tuptable->vals= (HeapTuple*)repalloc(tuptable->vals,
18031804
tuptable->alloced*sizeof(HeapTuple));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp