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

Commitfd734f3

Browse files
committed
Use pg_bitutils for HyperLogLog.
Using pg_leftmost_one_post32() yields substantial performance benefits.Backpatching to version 13 because HLL is used for HashAggimprovements in9878b64, which was also backpatched to 13.Reviewed-by: Peter GeogheganDiscussion:https://postgr.es/m/CAH2-WzkGvDKVDo+0YvfvZ+1CE=iCi88DCOGFF3i1hTGGaxcKPw@mail.gmail.comBackpatch-through: 13
1 parentf1af75c commitfd734f3

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

‎src/backend/lib/hyperloglog.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include<math.h>
5050

5151
#include"lib/hyperloglog.h"
52+
#include"port/pg_bitutils.h"
5253

5354
#definePOW_2_32(4294967296.0)
5455
#defineNEG_POW_2_32(-4294967296.0)
@@ -242,11 +243,13 @@ rho(uint32 x, uint8 b)
242243
{
243244
uint8j=1;
244245

245-
while (j <=b&& !(x&0x80000000))
246-
{
247-
j++;
248-
x <<=1;
249-
}
246+
if (x==0)
247+
returnb+1;
248+
249+
j=32-pg_leftmost_one_pos32(x);
250+
251+
if (j>b)
252+
returnb+1;
250253

251254
returnj;
252255
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp