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

Commit771cfe2

Browse files
Avoid unnecessary GinFormTuple() calls for incompressible posting lists.
Previously, we attempted to form a posting list tuple even whenginCompressPostingList() failed to compress the posting list due toits size. While there was no functional failure, it always wasted oneGinFormTuple() call when item pointers didn't fit in a posting listtuple.This commit ensures that a GIN index tuple is formed only when allitem pointers in the posting list are successfully compressed.Author: Arseniy Mukhin <arseniy.mukhin.dev@gmail.com>Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>Discussion:https://postgr.es/m/CAE7r3M+C=jcpTD93f_RBHrQp3C+=TAXFs+k4tTuZuuxboK8AvA@mail.gmail.com
1 parentec8719c commit771cfe2

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

‎src/backend/access/gin/gininsert.c‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ addItemPointersToLeafTuple(GinState *ginstate,
218218
ItemPointerData*newItems,
219219
*oldItems;
220220
intoldNPosting,
221-
newNPosting;
221+
newNPosting,
222+
nwritten;
222223
GinPostingList*compressedList;
223224

224225
Assert(!GinIsPostingTree(old));
@@ -235,18 +236,19 @@ addItemPointersToLeafTuple(GinState *ginstate,
235236

236237
/* Compress the posting list, and try to a build tuple with room for it */
237238
res=NULL;
238-
compressedList=ginCompressPostingList(newItems,newNPosting,GinMaxItemSize,
239-
NULL);
240-
pfree(newItems);
241-
if (compressedList)
239+
compressedList=ginCompressPostingList(newItems,newNPosting,GinMaxItemSize,&nwritten);
240+
if (nwritten==newNPosting)
242241
{
243242
res=GinFormTuple(ginstate,attnum,key,category,
244243
(char*)compressedList,
245244
SizeOfGinPostingList(compressedList),
246245
newNPosting,
247246
false);
248-
pfree(compressedList);
249247
}
248+
249+
pfree(newItems);
250+
pfree(compressedList);
251+
250252
if (!res)
251253
{
252254
/* posting list would be too big, convert to posting tree */
@@ -293,17 +295,19 @@ buildFreshLeafTuple(GinState *ginstate,
293295
{
294296
IndexTupleres=NULL;
295297
GinPostingList*compressedList;
298+
intnwritten;
296299

297300
/* try to build a posting list tuple with all the items */
298-
compressedList=ginCompressPostingList(items,nitem,GinMaxItemSize,NULL);
299-
if (compressedList)
301+
compressedList=ginCompressPostingList(items,nitem,GinMaxItemSize,&nwritten);
302+
if (nwritten==nitem)
300303
{
301304
res=GinFormTuple(ginstate,attnum,key,category,
302305
(char*)compressedList,
303306
SizeOfGinPostingList(compressedList),
304307
nitem, false);
305-
pfree(compressedList);
306308
}
309+
pfree(compressedList);
310+
307311
if (!res)
308312
{
309313
/* posting list would be too big, build posting tree */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp