跳转到主要内容

pgx_ulid

ulid type and methods

pgx_ulid : ulid type and methods

Overview

ID Extension Package Version Category License Language
4510 pgx_ulid pgx_ulid 0.2.3 FUNC MIT Rust
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--sLd-- No Yes Yes Yes no no
shared_preload_libraries = pgx_ulid is only required for gen_monotonic_ulid(); other functions work without it.

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT PIGSTY 0.2.3 18 17 16 15 14 pgx_ulid -
RPM PIGSTY 0.2.3 18 17 16 15 14 pgx_ulid_$v -
DEB PIGSTY 0.2.3 18 17 16 15 14 postgresql-$v-pgx-ulid -
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3
el8.aarch64 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3
el9.x86_64 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3
el9.aarch64 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3
el10.x86_64 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3
el10.aarch64 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3
d12.x86_64 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3
d12.aarch64 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3
d13.x86_64 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3
d13.aarch64 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3
u22.x86_64 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3
u22.aarch64 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3
u24.x86_64 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3
u24.aarch64 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3
u26.x86_64 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3
u26.aarch64 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3 PIGSTY 0.2.3
Package Version OS ORG SIZE File URL
pgx_ulid_18 0.2.3 el8.x86_64 pigsty 912.5 KiB pgx_ulid_18-0.2.3-3PIGSTY.el8.x86_64.rpm
pgx_ulid_18 0.2.3 el8.aarch64 pigsty 822.1 KiB pgx_ulid_18-0.2.3-3PIGSTY.el8.aarch64.rpm
pgx_ulid_18 0.2.3 el9.x86_64 pigsty 922.1 KiB pgx_ulid_18-0.2.3-3PIGSTY.el9.x86_64.rpm
pgx_ulid_18 0.2.3 el9.aarch64 pigsty 869.5 KiB pgx_ulid_18-0.2.3-3PIGSTY.el9.aarch64.rpm
pgx_ulid_18 0.2.3 el10.x86_64 pigsty 921.2 KiB pgx_ulid_18-0.2.3-3PIGSTY.el10.x86_64.rpm
pgx_ulid_18 0.2.3 el10.aarch64 pigsty 849.5 KiB pgx_ulid_18-0.2.3-3PIGSTY.el10.aarch64.rpm
postgresql-18-pgx-ulid 0.2.3 d12.x86_64 pigsty 731.3 KiB postgresql-18-pgx-ulid_0.2.3-3PIGSTY~bookworm_amd64.deb
postgresql-18-pgx-ulid 0.2.3 d12.aarch64 pigsty 613.0 KiB postgresql-18-pgx-ulid_0.2.3-3PIGSTY~bookworm_arm64.deb
postgresql-18-pgx-ulid 0.2.3 d13.x86_64 pigsty 731.0 KiB postgresql-18-pgx-ulid_0.2.3-3PIGSTY~trixie_amd64.deb
postgresql-18-pgx-ulid 0.2.3 d13.aarch64 pigsty 613.5 KiB postgresql-18-pgx-ulid_0.2.3-3PIGSTY~trixie_arm64.deb
postgresql-18-pgx-ulid 0.2.3 u22.x86_64 pigsty 813.6 KiB postgresql-18-pgx-ulid_0.2.3-3PIGSTY~jammy_amd64.deb
postgresql-18-pgx-ulid 0.2.3 u22.aarch64 pigsty 722.2 KiB postgresql-18-pgx-ulid_0.2.3-3PIGSTY~jammy_arm64.deb
postgresql-18-pgx-ulid 0.2.3 u24.x86_64 pigsty 804.6 KiB postgresql-18-pgx-ulid_0.2.3-3PIGSTY~noble_amd64.deb
postgresql-18-pgx-ulid 0.2.3 u24.aarch64 pigsty 713.2 KiB postgresql-18-pgx-ulid_0.2.3-3PIGSTY~noble_arm64.deb
postgresql-18-pgx-ulid 0.2.3 u26.x86_64 pigsty 798.6 KiB postgresql-18-pgx-ulid_0.2.3-3PIGSTY~resolute_amd64.deb
postgresql-18-pgx-ulid 0.2.3 u26.aarch64 pigsty 710.9 KiB postgresql-18-pgx-ulid_0.2.3-3PIGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pgx_ulid_17 0.2.3 el8.x86_64 pigsty 909.6 KiB pgx_ulid_17-0.2.3-3PIGSTY.el8.x86_64.rpm
pgx_ulid_17 0.2.3 el8.aarch64 pigsty 819.1 KiB pgx_ulid_17-0.2.3-3PIGSTY.el8.aarch64.rpm
pgx_ulid_17 0.2.3 el9.x86_64 pigsty 916.5 KiB pgx_ulid_17-0.2.3-3PIGSTY.el9.x86_64.rpm
pgx_ulid_17 0.2.3 el9.aarch64 pigsty 866.6 KiB pgx_ulid_17-0.2.3-3PIGSTY.el9.aarch64.rpm
pgx_ulid_17 0.2.3 el10.x86_64 pigsty 918.2 KiB pgx_ulid_17-0.2.3-3PIGSTY.el10.x86_64.rpm
pgx_ulid_17 0.2.3 el10.aarch64 pigsty 849.1 KiB pgx_ulid_17-0.2.3-3PIGSTY.el10.aarch64.rpm
postgresql-17-pgx-ulid 0.2.3 d12.x86_64 pigsty 728.6 KiB postgresql-17-pgx-ulid_0.2.3-3PIGSTY~bookworm_amd64.deb
postgresql-17-pgx-ulid 0.2.3 d12.aarch64 pigsty 611.6 KiB postgresql-17-pgx-ulid_0.2.3-3PIGSTY~bookworm_arm64.deb
postgresql-17-pgx-ulid 0.2.3 d13.x86_64 pigsty 728.8 KiB postgresql-17-pgx-ulid_0.2.3-3PIGSTY~trixie_amd64.deb
postgresql-17-pgx-ulid 0.2.3 d13.aarch64 pigsty 612.2 KiB postgresql-17-pgx-ulid_0.2.3-3PIGSTY~trixie_arm64.deb
postgresql-17-pgx-ulid 0.2.3 u22.x86_64 pigsty 811.2 KiB postgresql-17-pgx-ulid_0.2.3-3PIGSTY~jammy_amd64.deb
postgresql-17-pgx-ulid 0.2.3 u22.aarch64 pigsty 719.0 KiB postgresql-17-pgx-ulid_0.2.3-3PIGSTY~jammy_arm64.deb
postgresql-17-pgx-ulid 0.2.3 u24.x86_64 pigsty 802.4 KiB postgresql-17-pgx-ulid_0.2.3-3PIGSTY~noble_amd64.deb
postgresql-17-pgx-ulid 0.2.3 u24.aarch64 pigsty 710.8 KiB postgresql-17-pgx-ulid_0.2.3-3PIGSTY~noble_arm64.deb
postgresql-17-pgx-ulid 0.2.3 u26.x86_64 pigsty 797.4 KiB postgresql-17-pgx-ulid_0.2.3-3PIGSTY~resolute_amd64.deb
postgresql-17-pgx-ulid 0.2.3 u26.aarch64 pigsty 709.1 KiB postgresql-17-pgx-ulid_0.2.3-3PIGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pgx_ulid_16 0.2.3 el8.x86_64 pigsty 908.8 KiB pgx_ulid_16-0.2.3-3PIGSTY.el8.x86_64.rpm
pgx_ulid_16 0.2.3 el8.aarch64 pigsty 817.0 KiB pgx_ulid_16-0.2.3-3PIGSTY.el8.aarch64.rpm
pgx_ulid_16 0.2.3 el9.x86_64 pigsty 918.3 KiB pgx_ulid_16-0.2.3-3PIGSTY.el9.x86_64.rpm
pgx_ulid_16 0.2.3 el9.aarch64 pigsty 864.6 KiB pgx_ulid_16-0.2.3-3PIGSTY.el9.aarch64.rpm
pgx_ulid_16 0.2.3 el10.x86_64 pigsty 917.7 KiB pgx_ulid_16-0.2.3-3PIGSTY.el10.x86_64.rpm
pgx_ulid_16 0.2.3 el10.aarch64 pigsty 848.3 KiB pgx_ulid_16-0.2.3-3PIGSTY.el10.aarch64.rpm
postgresql-16-pgx-ulid 0.2.3 d12.x86_64 pigsty 728.4 KiB postgresql-16-pgx-ulid_0.2.3-3PIGSTY~bookworm_amd64.deb
postgresql-16-pgx-ulid 0.2.3 d12.aarch64 pigsty 611.0 KiB postgresql-16-pgx-ulid_0.2.3-3PIGSTY~bookworm_arm64.deb
postgresql-16-pgx-ulid 0.2.3 d13.x86_64 pigsty 729.1 KiB postgresql-16-pgx-ulid_0.2.3-3PIGSTY~trixie_amd64.deb
postgresql-16-pgx-ulid 0.2.3 d13.aarch64 pigsty 611.3 KiB postgresql-16-pgx-ulid_0.2.3-3PIGSTY~trixie_arm64.deb
postgresql-16-pgx-ulid 0.2.3 u22.x86_64 pigsty 811.1 KiB postgresql-16-pgx-ulid_0.2.3-3PIGSTY~jammy_amd64.deb
postgresql-16-pgx-ulid 0.2.3 u22.aarch64 pigsty 717.8 KiB postgresql-16-pgx-ulid_0.2.3-3PIGSTY~jammy_arm64.deb
postgresql-16-pgx-ulid 0.2.3 u24.x86_64 pigsty 802.4 KiB postgresql-16-pgx-ulid_0.2.3-3PIGSTY~noble_amd64.deb
postgresql-16-pgx-ulid 0.2.3 u24.aarch64 pigsty 709.3 KiB postgresql-16-pgx-ulid_0.2.3-3PIGSTY~noble_arm64.deb
postgresql-16-pgx-ulid 0.2.3 u26.x86_64 pigsty 797.4 KiB postgresql-16-pgx-ulid_0.2.3-3PIGSTY~resolute_amd64.deb
postgresql-16-pgx-ulid 0.2.3 u26.aarch64 pigsty 708.8 KiB postgresql-16-pgx-ulid_0.2.3-3PIGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pgx_ulid_15 0.2.3 el8.x86_64 pigsty 898.5 KiB pgx_ulid_15-0.2.3-3PIGSTY.el8.x86_64.rpm
pgx_ulid_15 0.2.3 el8.aarch64 pigsty 808.6 KiB pgx_ulid_15-0.2.3-3PIGSTY.el8.aarch64.rpm
pgx_ulid_15 0.2.3 el9.x86_64 pigsty 907.9 KiB pgx_ulid_15-0.2.3-3PIGSTY.el9.x86_64.rpm
pgx_ulid_15 0.2.3 el9.aarch64 pigsty 855.8 KiB pgx_ulid_15-0.2.3-3PIGSTY.el9.aarch64.rpm
pgx_ulid_15 0.2.3 el10.x86_64 pigsty 906.1 KiB pgx_ulid_15-0.2.3-3PIGSTY.el10.x86_64.rpm
pgx_ulid_15 0.2.3 el10.aarch64 pigsty 844.6 KiB pgx_ulid_15-0.2.3-3PIGSTY.el10.aarch64.rpm
postgresql-15-pgx-ulid 0.2.3 d12.x86_64 pigsty 722.1 KiB postgresql-15-pgx-ulid_0.2.3-3PIGSTY~bookworm_amd64.deb
postgresql-15-pgx-ulid 0.2.3 d12.aarch64 pigsty 606.5 KiB postgresql-15-pgx-ulid_0.2.3-3PIGSTY~bookworm_arm64.deb
postgresql-15-pgx-ulid 0.2.3 d13.x86_64 pigsty 722.4 KiB postgresql-15-pgx-ulid_0.2.3-3PIGSTY~trixie_amd64.deb
postgresql-15-pgx-ulid 0.2.3 d13.aarch64 pigsty 606.9 KiB postgresql-15-pgx-ulid_0.2.3-3PIGSTY~trixie_arm64.deb
postgresql-15-pgx-ulid 0.2.3 u22.x86_64 pigsty 801.8 KiB postgresql-15-pgx-ulid_0.2.3-3PIGSTY~jammy_amd64.deb
postgresql-15-pgx-ulid 0.2.3 u22.aarch64 pigsty 713.0 KiB postgresql-15-pgx-ulid_0.2.3-3PIGSTY~jammy_arm64.deb
postgresql-15-pgx-ulid 0.2.3 u24.x86_64 pigsty 793.5 KiB postgresql-15-pgx-ulid_0.2.3-3PIGSTY~noble_amd64.deb
postgresql-15-pgx-ulid 0.2.3 u24.aarch64 pigsty 704.7 KiB postgresql-15-pgx-ulid_0.2.3-3PIGSTY~noble_arm64.deb
postgresql-15-pgx-ulid 0.2.3 u26.x86_64 pigsty 789.2 KiB postgresql-15-pgx-ulid_0.2.3-3PIGSTY~resolute_amd64.deb
postgresql-15-pgx-ulid 0.2.3 u26.aarch64 pigsty 702.1 KiB postgresql-15-pgx-ulid_0.2.3-3PIGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pgx_ulid_14 0.2.3 el8.x86_64 pigsty 895.5 KiB pgx_ulid_14-0.2.3-3PIGSTY.el8.x86_64.rpm
pgx_ulid_14 0.2.3 el8.aarch64 pigsty 805.1 KiB pgx_ulid_14-0.2.3-3PIGSTY.el8.aarch64.rpm
pgx_ulid_14 0.2.3 el9.x86_64 pigsty 904.4 KiB pgx_ulid_14-0.2.3-3PIGSTY.el9.x86_64.rpm
pgx_ulid_14 0.2.3 el9.aarch64 pigsty 852.6 KiB pgx_ulid_14-0.2.3-3PIGSTY.el9.aarch64.rpm
pgx_ulid_14 0.2.3 el10.x86_64 pigsty 903.5 KiB pgx_ulid_14-0.2.3-3PIGSTY.el10.x86_64.rpm
pgx_ulid_14 0.2.3 el10.aarch64 pigsty 841.7 KiB pgx_ulid_14-0.2.3-3PIGSTY.el10.aarch64.rpm
postgresql-14-pgx-ulid 0.2.3 d12.x86_64 pigsty 720.0 KiB postgresql-14-pgx-ulid_0.2.3-3PIGSTY~bookworm_amd64.deb
postgresql-14-pgx-ulid 0.2.3 d12.aarch64 pigsty 604.4 KiB postgresql-14-pgx-ulid_0.2.3-3PIGSTY~bookworm_arm64.deb
postgresql-14-pgx-ulid 0.2.3 d13.x86_64 pigsty 719.5 KiB postgresql-14-pgx-ulid_0.2.3-3PIGSTY~trixie_amd64.deb
postgresql-14-pgx-ulid 0.2.3 d13.aarch64 pigsty 605.1 KiB postgresql-14-pgx-ulid_0.2.3-3PIGSTY~trixie_arm64.deb
postgresql-14-pgx-ulid 0.2.3 u22.x86_64 pigsty 798.7 KiB postgresql-14-pgx-ulid_0.2.3-3PIGSTY~jammy_amd64.deb
postgresql-14-pgx-ulid 0.2.3 u22.aarch64 pigsty 712.7 KiB postgresql-14-pgx-ulid_0.2.3-3PIGSTY~jammy_arm64.deb
postgresql-14-pgx-ulid 0.2.3 u24.x86_64 pigsty 790.9 KiB postgresql-14-pgx-ulid_0.2.3-3PIGSTY~noble_amd64.deb
postgresql-14-pgx-ulid 0.2.3 u24.aarch64 pigsty 701.8 KiB postgresql-14-pgx-ulid_0.2.3-3PIGSTY~noble_arm64.deb
postgresql-14-pgx-ulid 0.2.3 u26.x86_64 pigsty 787.0 KiB postgresql-14-pgx-ulid_0.2.3-3PIGSTY~resolute_amd64.deb
postgresql-14-pgx-ulid 0.2.3 u26.aarch64 pigsty 700.2 KiB postgresql-14-pgx-ulid_0.2.3-3PIGSTY~resolute_arm64.deb

Source

pig build pkg pgx_ulid;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pgx_ulid;		# install via package name, for the active PG version

pig install pgx_ulid -v 18;   # install for PG 18
pig install pgx_ulid -v 17;   # install for PG 17
pig install pgx_ulid -v 16;   # install for PG 16
pig install pgx_ulid -v 15;   # install for PG 15
pig install pgx_ulid -v 14;   # install for PG 14

Config this extension to shared_preload_libraries:

shared_preload_libraries = 'pgx_ulid';

Create this extension with:

CREATE EXTENSION pgx_ulid;

Usage

Sources: README, releases

pgx_ulid provides a native ulid type, generators, and casts to and from timestamp and uuid. The README documents binary storage and monotonic ULID support. The pgext catalog tracks package and extension name pgx_ulid, version 0.2.3, for PostgreSQL 14-18.

Enable the extension

CREATE EXTENSION pgx_ulid;

Generate ULIDs

SELECT gen_ulid();
SELECT gen_monotonic_ulid();

gen_monotonic_ulid() needs:

shared_preload_libraries = 'pgx_ulid'

The README explicitly says this preload requirement only affects gen_monotonic_ulid(); the rest of the extension works without it.

Use ulid as a primary key

CREATE TABLE users (
  id ulid NOT NULL DEFAULT gen_ulid() PRIMARY KEY,
  name text NOT NULL
);

SELECT * FROM users
WHERE id = '01ARZ3NDEKTSV4RRFFQ69G5FAV';

Casts and range queries

ALTER TABLE users
ADD COLUMN created_at timestamp GENERATED ALWAYS AS (id::timestamp) STORED;

SELECT * FROM users
WHERE id BETWEEN '2023-09-15'::timestamp::ulid
            AND '2023-09-16'::timestamp::ulid;

The README also documents casts between ulid and uuid.

Caveats

  • Monotonic ULIDs use shared memory plus an LWLock to keep the last generated value.
  • The README notes that monotonic generation can theoretically overflow and raise an error, although it treats this as negligible in practice.
  • The upstream README also shows CREATE EXTENSION ulid; this stub follows db/extension.csv, where the package and lead extension are both pgx_ulid.
  • The GitHub release page lists v0.2.3 as latest and only labels it Release 0.2.3, with no separate user-facing release notes.