Skip to content

Commit ea7dace

Browse files
committed
Simplify/speed up assertion cross-check in ginCompressPostingList().
I noticed while testing some other stuff that the CHECK_ENCODING_ROUNDTRIP logic in ginCompressPostingList could account for over 50% of the runtime of an INSERT with a GIN index. While that's not relevant to production performance, it's still kind of annoying in a debug build. Replacing the loop around short memcmp's with one long memcmp works just as well and is significantly faster, at least on my machine.
1 parent 7e39b96 commit ea7dace

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/backend/access/gin/ginpostinglist.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,9 @@ ginCompressPostingList(const ItemPointer ipd, int nipd, int maxsize,
266266
{
267267
int ndecoded;
268268
ItemPointer tmp = ginPostingListDecode(result, &ndecoded);
269-
int i;
270269

271270
Assert(ndecoded == totalpacked);
272-
for (i = 0; i < ndecoded; i++)
273-
Assert(memcmp(&tmp[i], &ipd[i], sizeof(ItemPointerData)) == 0);
271+
Assert(memcmp(tmp, ipd, ndecoded * sizeof(ItemPointerData)) == 0);
274272
pfree(tmp);
275273
}
276274
#endif

0 commit comments

Comments
 (0)