postgrespro.git / summary / log / commit / refs

commit    ea7dace2aa21e79a7a8eb23c493bcd2057d9bd7e
Author:   Tom Lane <tgl@sss.pgh.pa.us>
Date:     Sat Mar 07 18:31:17 2020 +0000

    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.


src/backend/access/gin/ginpostinglist.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/backend/access/gin/ginpostinglist.c b/src/backend/access/gin/ginpostinglist.c index 7dff2071d8..461ec93fde 100644 --- a/src/backend/access/gin/ginpostinglist.c +++ b/src/backend/access/gin/ginpostinglist.c @@ -266,11 +266,9 @@ ginCompressPostingList(const ItemPointer ipd, int nipd, int maxsize, { int ndecoded; ItemPointer tmp = ginPostingListDecode(result, &ndecoded); - int i; Assert(ndecoded == totalpacked); - for (i = 0; i < ndecoded; i++) - Assert(memcmp(&tmp[i], &ipd[i], sizeof(ItemPointerData)) == 0); + Assert(memcmp(tmp, ipd, ndecoded * sizeof(ItemPointerData)) == 0); pfree(tmp); } #endif [parent: 7e39b968f118]