Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse bytes rather than chars #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

NathanBaulch
Copy link

Very handy functions, just what I needed!

I was looking over your parse function and couldn't help but wonder if processing the ulid as bytes rather than chars might improve performance. Turns out it does, by a factor of about 2x in my tests!

-- parse a million sequential ULIDs
select count(parse_ulid_mine(concat('0', i))) from generate_series(1e24, 1e24 - 1 + 1e6) as i;
-- mine: 23.619s
select count(parse_ulid_yours(concat('0', i))) from generate_series(1e24, 1e24 - 1 + 1e6) as i;
-- yours: 49.648s

FWIW, I'm running Pg 16.4 in Docker in WSL on Windows on a 7 year old notebook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant