diff options
| author | Heikki Linnakangas | 2013-06-29 09:54:02 +0000 |
|---|---|---|
| committer | Heikki Linnakangas | 2013-06-29 09:55:34 +0000 |
| commit | ee6556555b237c0feeb175e7ea7ce23af959e7ba (patch) | |
| tree | d2c56a8db21b0ab234c4a9ac71f881327662e8a1 /src/include/access | |
| parent | d51b271059ba736f71c5372f713d907f711208ec (diff) | |
Inline ginCompareItemPointers function for speed.
ginCompareItemPointers function is called heavily in gin index scans -
inlining it speeds up some kind of queries a lot.
Diffstat (limited to 'src/include/access')
| -rw-r--r-- | src/include/access/gin_private.h | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/include/access/gin_private.h b/src/include/access/gin_private.h index 1868b77df10..c603521c957 100644 --- a/src/include/access/gin_private.h +++ b/src/include/access/gin_private.h @@ -530,7 +530,6 @@ extern void ginEntryFillRoot(GinBtree btree, Buffer root, Buffer lbuf, Buffer rb extern IndexTuple ginPageGetLinkItup(Buffer buf); /* gindatapage.c */ -extern int ginCompareItemPointers(ItemPointer a, ItemPointer b); extern uint32 ginMergeItemPointers(ItemPointerData *dst, ItemPointerData *a, uint32 na, ItemPointerData *b, uint32 nb); @@ -724,4 +723,28 @@ extern void ginHeapTupleFastCollect(GinState *ginstate, extern void ginInsertCleanup(GinState *ginstate, bool vac_delay, IndexBulkDeleteResult *stats); +/* + * Merging the results of several gin scans compares item pointers a lot, + * so we want this to be inlined. But if the compiler doesn't support that, + * fall back on the non-inline version from itemptr.c. See STATIC_IF_INLINE in + * c.h. + */ +#ifdef PG_USE_INLINE +static inline int +ginCompareItemPointers(ItemPointer a, ItemPointer b) +{ + uint64 ia = (uint64) a->ip_blkid.bi_hi << 32 | (uint64) a->ip_blkid.bi_lo << 16 | a->ip_posid; + uint64 ib = (uint64) b->ip_blkid.bi_hi << 32 | (uint64) b->ip_blkid.bi_lo << 16 | b->ip_posid; + + if (ia == ib) + return 0; + else if (ia > ib) + return 1; + else + return -1; +} +#else +#define ginCompareItemPointers(a, b) ItemPointerCompare(a, b) +#endif /* PG_USE_INLINE */ + #endif /* GIN_PRIVATE_H */ |
