edoceo / pg-ulid

ULID Functions for PostgreSQL
59 stars 0 forks source link
postgresql postgresql-extension ulid

ULID Extension for PostgreSQL

Creates a ULID datatype as a 128bit integer, which we hope operates faster than text.

Creates some helper functions to create, compare and format

The ULID function is taken from [XXX] and other inspiration from [THE GO ONE]

Installation

Get this code, say make, copy the .so file to your PGHOME/xxx

sudo apt install build-essential postgresql-server-dev-NN
git clone https://github.com/skeeto/ulid-c.git
make
sudo make install-strip
CREATE EXTENSION pg_ulid;

Usage

SELECT ulid_create();
SELECT ulid_create(now() - '37 days'::interval);
CREATE TABLE ulid_pk_example (
    id ulid not null default ulid_create(),
    meta jsonb
);

Dependencies

See Also