pg_uuid_v8
pg_uuid_v8 : UUID v8 generator with embedded timestamps for PostgreSQL
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 4530 | pg_uuid_v8 | pg_uuid_v8 | 1.1.0 |
FUNC | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --s-d-- | No | Yes | No | Yes | no | no |
| Relationships | |
|---|---|
| Schemas | public |
| See Also | pg_uuidv7 sequential_uuids snowflake pg_idkit pgx_ulid uuid-ossp typeid permuteseq |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.1.0 |
18 17 16 15 14 | pg_uuid_v8 |
- |
| RPM | PIGSTY | 1.1.0 |
18 17 16 15 14 | pg_uuid_v8_$v |
openssl |
| DEB | PIGSTY | 1.1.0 |
18 17 16 15 14 | postgresql-$v-pg-uuid-v8 |
`libssl3 |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
| el8.aarch64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
| el9.x86_64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
| el9.aarch64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
| el10.x86_64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
| el10.aarch64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
| d12.x86_64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
| d12.aarch64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
| d13.x86_64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
| d13.aarch64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
| u22.x86_64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
| u22.aarch64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
| u24.x86_64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
| u24.aarch64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
| u26.x86_64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
| u26.aarch64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
Source
github.com/ineron/pg_uuid_v8
pg_uuid_v8-1.1.0.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Create this extension with:
Usage
Sources:
- pg_uuid_v8 1.1.0 on PGXN
- pg_uuid_v8 1.1.0 README
- pg_uuid_v8 1.1.0 control file
- pg_uuid_v8 1.0 base SQL
- pg_uuid_v8 1.0 to 1.1 upgrade SQL
- Pigsty pg_uuid_v8 package matrix
pg_uuid_v8 1.1.0 generates UUID values with UUID-v4 version and variant bits while embedding an obfuscated creation time in the random payload. Its uuid_v8_* convenience functions mirror the lower-level uuid_stego_* API. Use it when hidden time extraction and time-range indexing are useful, but do not treat the embedded value as an authentication token or a substitute for a separate trusted creation timestamp.
Generate Values
The upstream implementation defaults to a published built-in seed and XOR mode. Set a deployment-specific secret before generating values. AES128 and AES256 are also available, but the same seed and mode must be selected when extracting a value.
Extract and Index the Hidden Time
uuid_v8_extract_timestamp(uuid) returns a microsecond-scaled bigint so it remains compatible with timestamp_to_stego_time() and stego_time_to_timestamp(). In version 1.1 the internal 48-bit field stores milliseconds, so the returned value has millisecond resolution and its last three decimal digits are zero.
uuid_stego_in_range() offers a boolean timestamp-range helper. A functional B-tree index on the extraction function is the explicit and predictable path for indexed time predicates.
Compare Hidden Times
uuid_v8_compare(uuid, uuid) and uuid_stego_compare(uuid, uuid) return ordering by extracted hidden time. The extension also defines <, <=, >, and >= operators for UUID arguments.
Pigsty packages install these added operators in public and qualify their commutator and negator references for PostgreSQL 17 and 18 compatibility. PostgreSQL already has built-in UUID ordering operators, so use the comparison functions or a schema-qualified OPERATOR(public.<) expression when hidden-time semantics must be unambiguous.
Seed and Mode Controls
The seed is exposed as uuid_v8.stego_seed and the mode as uuid_v8.encryption_mode. Setter functions change the current session; configuration settings can establish defaults for later sessions. uuid_v8_get_seed() returns the active seed, so restrict database access accordingly and never log its result.
Upgrade and Compatibility Boundaries
Version 1.1 changes timestamp storage from microseconds to milliseconds. The old 48-bit microsecond field rolled over about every 8.9 years and could not reliably recover current absolute dates; the 48-bit millisecond field lasts about 8,925 years. Relative ordering of pre-1.1 values was unaffected, but absolute time extraction and range predicates for those existing values remain unreliable after the upgrade because their encoded representation is not rewritten.
The PGXN metadata targets PostgreSQL 12 or later; current Pigsty packages cover PostgreSQL 14–18. Pigsty packages pin the extension to public and make it non-relocatable so the added operators resolve consistently. Keep an ordinary created_at column when provenance, auditability, sub-millisecond precision, or migrations across seeds and modes matter.