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

Commitee65565

Browse files
committed
Inline ginCompareItemPointers function for speed.
ginCompareItemPointers function is called heavily in gin index scans -inlining it speeds up some kind of queries a lot.
1 parentd51b271 commitee65565

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,6 @@
1717
#include"access/gin_private.h"
1818
#include"utils/rel.h"
1919

20-
int
21-
ginCompareItemPointers(ItemPointera,ItemPointerb)
22-
{
23-
BlockNumberba=GinItemPointerGetBlockNumber(a);
24-
BlockNumberbb=GinItemPointerGetBlockNumber(b);
25-
26-
if (ba==bb)
27-
{
28-
OffsetNumberoa=GinItemPointerGetOffsetNumber(a);
29-
OffsetNumberob=GinItemPointerGetOffsetNumber(b);
30-
31-
if (oa==ob)
32-
return0;
33-
return (oa>ob) ?1 :-1;
34-
}
35-
36-
return (ba>bb) ?1 :-1;
37-
}
38-
3920
/*
4021
* Merge two ordered arrays of itempointers, eliminating any duplicates.
4122
* Returns the number of items in the result.

‎src/include/access/gin_private.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,6 @@ extern void ginEntryFillRoot(GinBtree btree, Buffer root, Buffer lbuf, Buffer rb
530530
externIndexTupleginPageGetLinkItup(Bufferbuf);
531531

532532
/* gindatapage.c */
533-
externintginCompareItemPointers(ItemPointera,ItemPointerb);
534533
externuint32ginMergeItemPointers(ItemPointerData*dst,
535534
ItemPointerData*a,uint32na,
536535
ItemPointerData*b,uint32nb);
@@ -724,4 +723,28 @@ extern void ginHeapTupleFastCollect(GinState *ginstate,
724723
externvoidginInsertCleanup(GinState*ginstate,
725724
boolvac_delay,IndexBulkDeleteResult*stats);
726725

726+
/*
727+
* Merging the results of several gin scans compares item pointers a lot,
728+
* so we want this to be inlined. But if the compiler doesn't support that,
729+
* fall back on the non-inline version from itemptr.c. See STATIC_IF_INLINE in
730+
* c.h.
731+
*/
732+
#ifdefPG_USE_INLINE
733+
staticinlineint
734+
ginCompareItemPointers(ItemPointera,ItemPointerb)
735+
{
736+
uint64ia= (uint64)a->ip_blkid.bi_hi <<32 | (uint64)a->ip_blkid.bi_lo <<16 |a->ip_posid;
737+
uint64ib= (uint64)b->ip_blkid.bi_hi <<32 | (uint64)b->ip_blkid.bi_lo <<16 |b->ip_posid;
738+
739+
if (ia==ib)
740+
return0;
741+
elseif (ia>ib)
742+
return1;
743+
else
744+
return-1;
745+
}
746+
#else
747+
#defineginCompareItemPointers(a,b) ItemPointerCompare(a, b)
748+
#endif/* PG_USE_INLINE */
749+
727750
#endif/* GIN_PRIVATE_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp