pgx_ulid

pgx_ulid

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
Relationships
See Also
pg_idkit
pg_uuidv7
sequential_uuids
uuid-ossp
pg_hashids
permuteseq

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
Package Version OS ORG SIZE File URL
pgx_ulid_18 0.2.3 el8.x86_64 pigsty 389.2 KiB pgx_ulid_18-0.2.3-1PIGSTY.el8.x86_64.rpm
pgx_ulid_18 0.2.3 el8.aarch64 pigsty 273.2 KiB pgx_ulid_18-0.2.3-1PIGSTY.el8.aarch64.rpm
pgx_ulid_18 0.2.3 el9.x86_64 pigsty 406.5 KiB pgx_ulid_18-0.2.3-1PIGSTY.el9.x86_64.rpm
pgx_ulid_18 0.2.3 el9.aarch64 pigsty 292.5 KiB pgx_ulid_18-0.2.3-1PIGSTY.el9.aarch64.rpm
pgx_ulid_18 0.2.3 el10.x86_64 pigsty 406.4 KiB pgx_ulid_18-0.2.3-1PIGSTY.el10.x86_64.rpm
pgx_ulid_18 0.2.3 el10.aarch64 pigsty 292.4 KiB pgx_ulid_18-0.2.3-1PIGSTY.el10.aarch64.rpm
postgresql-18-pgx-ulid 0.2.3 d12.x86_64 pigsty 322.2 KiB postgresql-18-pgx-ulid_0.2.3-1PIGSTY~bookworm_amd64.deb
postgresql-18-pgx-ulid 0.2.3 d12.aarch64 pigsty 213.3 KiB postgresql-18-pgx-ulid_0.2.3-1PIGSTY~bookworm_arm64.deb
postgresql-18-pgx-ulid 0.2.3 d13.x86_64 pigsty 322.2 KiB postgresql-18-pgx-ulid_0.2.3-1PIGSTY~trixie_amd64.deb
postgresql-18-pgx-ulid 0.2.3 d13.aarch64 pigsty 213.2 KiB postgresql-18-pgx-ulid_0.2.3-1PIGSTY~trixie_arm64.deb
postgresql-18-pgx-ulid 0.2.3 u22.x86_64 pigsty 363.4 KiB postgresql-18-pgx-ulid_0.2.3-1PIGSTY~jammy_amd64.deb
postgresql-18-pgx-ulid 0.2.3 u22.aarch64 pigsty 247.7 KiB postgresql-18-pgx-ulid_0.2.3-1PIGSTY~jammy_arm64.deb
postgresql-18-pgx-ulid 0.2.3 u24.x86_64 pigsty 360.1 KiB postgresql-18-pgx-ulid_0.2.3-1PIGSTY~noble_amd64.deb
postgresql-18-pgx-ulid 0.2.3 u24.aarch64 pigsty 246.0 KiB postgresql-18-pgx-ulid_0.2.3-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pgx_ulid_17 0.2.3 el8.x86_64 pigsty 389.2 KiB pgx_ulid_17-0.2.3-1PIGSTY.el8.x86_64.rpm
pgx_ulid_17 0.2.3 el8.aarch64 pigsty 273.1 KiB pgx_ulid_17-0.2.3-1PIGSTY.el8.aarch64.rpm
pgx_ulid_17 0.2.3 el9.x86_64 pigsty 406.5 KiB pgx_ulid_17-0.2.3-1PIGSTY.el9.x86_64.rpm
pgx_ulid_17 0.2.3 el9.aarch64 pigsty 292.6 KiB pgx_ulid_17-0.2.3-1PIGSTY.el9.aarch64.rpm
pgx_ulid_17 0.2.3 el10.x86_64 pigsty 406.7 KiB pgx_ulid_17-0.2.3-1PIGSTY.el10.x86_64.rpm
pgx_ulid_17 0.2.3 el10.aarch64 pigsty 292.4 KiB pgx_ulid_17-0.2.3-1PIGSTY.el10.aarch64.rpm
postgresql-17-pgx-ulid 0.2.3 d12.x86_64 pigsty 322.5 KiB postgresql-17-pgx-ulid_0.2.3-1PIGSTY~bookworm_amd64.deb
postgresql-17-pgx-ulid 0.2.3 d12.aarch64 pigsty 213.1 KiB postgresql-17-pgx-ulid_0.2.3-1PIGSTY~bookworm_arm64.deb
postgresql-17-pgx-ulid 0.2.3 d13.x86_64 pigsty 322.2 KiB postgresql-17-pgx-ulid_0.2.3-1PIGSTY~trixie_amd64.deb
postgresql-17-pgx-ulid 0.2.3 d13.aarch64 pigsty 213.1 KiB postgresql-17-pgx-ulid_0.2.3-1PIGSTY~trixie_arm64.deb
postgresql-17-pgx-ulid 0.2.3 u22.x86_64 pigsty 362.9 KiB postgresql-17-pgx-ulid_0.2.3-1PIGSTY~jammy_amd64.deb
postgresql-17-pgx-ulid 0.2.3 u22.aarch64 pigsty 247.8 KiB postgresql-17-pgx-ulid_0.2.3-1PIGSTY~jammy_arm64.deb
postgresql-17-pgx-ulid 0.2.3 u24.x86_64 pigsty 360.1 KiB postgresql-17-pgx-ulid_0.2.3-1PIGSTY~noble_amd64.deb
postgresql-17-pgx-ulid 0.2.3 u24.aarch64 pigsty 245.9 KiB postgresql-17-pgx-ulid_0.2.3-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pgx_ulid_16 0.2.3 el8.x86_64 pigsty 389.3 KiB pgx_ulid_16-0.2.3-1PIGSTY.el8.x86_64.rpm
pgx_ulid_16 0.2.3 el8.aarch64 pigsty 273.0 KiB pgx_ulid_16-0.2.3-1PIGSTY.el8.aarch64.rpm
pgx_ulid_16 0.2.3 el9.x86_64 pigsty 406.6 KiB pgx_ulid_16-0.2.3-1PIGSTY.el9.x86_64.rpm
pgx_ulid_16 0.2.3 el9.aarch64 pigsty 292.8 KiB pgx_ulid_16-0.2.3-1PIGSTY.el9.aarch64.rpm
pgx_ulid_16 0.2.3 el10.x86_64 pigsty 407.1 KiB pgx_ulid_16-0.2.3-1PIGSTY.el10.x86_64.rpm
pgx_ulid_16 0.2.3 el10.aarch64 pigsty 292.4 KiB pgx_ulid_16-0.2.3-1PIGSTY.el10.aarch64.rpm
postgresql-16-pgx-ulid 0.2.3 d12.x86_64 pigsty 322.7 KiB postgresql-16-pgx-ulid_0.2.3-1PIGSTY~bookworm_amd64.deb
postgresql-16-pgx-ulid 0.2.3 d12.aarch64 pigsty 213.4 KiB postgresql-16-pgx-ulid_0.2.3-1PIGSTY~bookworm_arm64.deb
postgresql-16-pgx-ulid 0.2.3 d13.x86_64 pigsty 322.7 KiB postgresql-16-pgx-ulid_0.2.3-1PIGSTY~trixie_amd64.deb
postgresql-16-pgx-ulid 0.2.3 d13.aarch64 pigsty 213.3 KiB postgresql-16-pgx-ulid_0.2.3-1PIGSTY~trixie_arm64.deb
postgresql-16-pgx-ulid 0.2.3 u22.x86_64 pigsty 362.7 KiB postgresql-16-pgx-ulid_0.2.3-1PIGSTY~jammy_amd64.deb
postgresql-16-pgx-ulid 0.2.3 u22.aarch64 pigsty 247.7 KiB postgresql-16-pgx-ulid_0.2.3-1PIGSTY~jammy_arm64.deb
postgresql-16-pgx-ulid 0.2.3 u24.x86_64 pigsty 359.7 KiB postgresql-16-pgx-ulid_0.2.3-1PIGSTY~noble_amd64.deb
postgresql-16-pgx-ulid 0.2.3 u24.aarch64 pigsty 245.9 KiB postgresql-16-pgx-ulid_0.2.3-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pgx_ulid_15 0.2.3 el8.x86_64 pigsty 389.0 KiB pgx_ulid_15-0.2.3-1PIGSTY.el8.x86_64.rpm
pgx_ulid_15 0.2.3 el8.aarch64 pigsty 273.1 KiB pgx_ulid_15-0.2.3-1PIGSTY.el8.aarch64.rpm
pgx_ulid_15 0.2.3 el9.x86_64 pigsty 406.4 KiB pgx_ulid_15-0.2.3-1PIGSTY.el9.x86_64.rpm
pgx_ulid_15 0.2.3 el9.aarch64 pigsty 292.5 KiB pgx_ulid_15-0.2.3-1PIGSTY.el9.aarch64.rpm
pgx_ulid_15 0.2.3 el10.x86_64 pigsty 406.5 KiB pgx_ulid_15-0.2.3-1PIGSTY.el10.x86_64.rpm
pgx_ulid_15 0.2.3 el10.aarch64 pigsty 292.3 KiB pgx_ulid_15-0.2.3-1PIGSTY.el10.aarch64.rpm
postgresql-15-pgx-ulid 0.2.3 d12.x86_64 pigsty 322.6 KiB postgresql-15-pgx-ulid_0.2.3-1PIGSTY~bookworm_amd64.deb
postgresql-15-pgx-ulid 0.2.3 d12.aarch64 pigsty 213.2 KiB postgresql-15-pgx-ulid_0.2.3-1PIGSTY~bookworm_arm64.deb
postgresql-15-pgx-ulid 0.2.3 d13.x86_64 pigsty 322.6 KiB postgresql-15-pgx-ulid_0.2.3-1PIGSTY~trixie_amd64.deb
postgresql-15-pgx-ulid 0.2.3 d13.aarch64 pigsty 213.1 KiB postgresql-15-pgx-ulid_0.2.3-1PIGSTY~trixie_arm64.deb
postgresql-15-pgx-ulid 0.2.3 u22.x86_64 pigsty 362.8 KiB postgresql-15-pgx-ulid_0.2.3-1PIGSTY~jammy_amd64.deb
postgresql-15-pgx-ulid 0.2.3 u22.aarch64 pigsty 247.7 KiB postgresql-15-pgx-ulid_0.2.3-1PIGSTY~jammy_arm64.deb
postgresql-15-pgx-ulid 0.2.3 u24.x86_64 pigsty 360.3 KiB postgresql-15-pgx-ulid_0.2.3-1PIGSTY~noble_amd64.deb
postgresql-15-pgx-ulid 0.2.3 u24.aarch64 pigsty 246.0 KiB postgresql-15-pgx-ulid_0.2.3-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pgx_ulid_14 0.2.3 el8.x86_64 pigsty 388.4 KiB pgx_ulid_14-0.2.3-1PIGSTY.el8.x86_64.rpm
pgx_ulid_14 0.2.3 el8.aarch64 pigsty 272.4 KiB pgx_ulid_14-0.2.3-1PIGSTY.el8.aarch64.rpm
pgx_ulid_14 0.2.3 el9.x86_64 pigsty 405.5 KiB pgx_ulid_14-0.2.3-1PIGSTY.el9.x86_64.rpm
pgx_ulid_14 0.2.3 el9.aarch64 pigsty 291.6 KiB pgx_ulid_14-0.2.3-1PIGSTY.el9.aarch64.rpm
pgx_ulid_14 0.2.3 el10.x86_64 pigsty 406.2 KiB pgx_ulid_14-0.2.3-1PIGSTY.el10.x86_64.rpm
pgx_ulid_14 0.2.3 el10.aarch64 pigsty 291.5 KiB pgx_ulid_14-0.2.3-1PIGSTY.el10.aarch64.rpm
postgresql-14-pgx-ulid 0.2.3 d12.x86_64 pigsty 322.0 KiB postgresql-14-pgx-ulid_0.2.3-1PIGSTY~bookworm_amd64.deb
postgresql-14-pgx-ulid 0.2.3 d12.aarch64 pigsty 213.0 KiB postgresql-14-pgx-ulid_0.2.3-1PIGSTY~bookworm_arm64.deb
postgresql-14-pgx-ulid 0.2.3 d13.x86_64 pigsty 322.2 KiB postgresql-14-pgx-ulid_0.2.3-1PIGSTY~trixie_amd64.deb
postgresql-14-pgx-ulid 0.2.3 d13.aarch64 pigsty 212.6 KiB postgresql-14-pgx-ulid_0.2.3-1PIGSTY~trixie_arm64.deb
postgresql-14-pgx-ulid 0.2.3 u22.x86_64 pigsty 362.6 KiB postgresql-14-pgx-ulid_0.2.3-1PIGSTY~jammy_amd64.deb
postgresql-14-pgx-ulid 0.2.3 u22.aarch64 pigsty 247.1 KiB postgresql-14-pgx-ulid_0.2.3-1PIGSTY~jammy_arm64.deb
postgresql-14-pgx-ulid 0.2.3 u24.x86_64 pigsty 359.4 KiB postgresql-14-pgx-ulid_0.2.3-1PIGSTY~noble_amd64.deb
postgresql-14-pgx-ulid 0.2.3 u24.aarch64 pigsty 245.2 KiB postgresql-14-pgx-ulid_0.2.3-1PIGSTY~noble_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

pgx_ulid: ULID type and methods for PostgreSQL

CREATE EXTENSION pgx_ulid;

ULID Type

The extension provides a native ulid type – a 26-character, lexicographically sortable identifier stored in binary.

Functions

Function Description
gen_ulid() Generate a new ULID
gen_monotonic_ulid() Generate monotonically increasing ULIDs (requires shared_preload_libraries)

Casting

  • ulid::timestamp – extract creation time from a ULID
  • timestamp::ulid – produce a ULID from a timestamp (zeroed random part)
  • ulid::uuid / uuid::ulid – convert between ULID and UUID

Examples

-- Use ULID as a primary key
CREATE TABLE users (
  id ulid NOT NULL DEFAULT gen_ulid() PRIMARY KEY,
  name text NOT NULL
);

-- Query by text representation
SELECT * FROM users WHERE id = '01ARZ3NDEKTSV4RRFFQ69G5FAV';

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

-- Range query by date
SELECT * FROM users
WHERE id BETWEEN '2023-09-15'::timestamp::ulid AND '2023-09-16'::timestamp::ulid;
Last updated on