pg_lexo
Overview
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 3530 | pg_lexo | No | Yes | No | Yes | No | No | - |
| Related | base62 pg_hashids typeid sequential_uuids |
|---|
Release/package 0.6.1 ships SQL/control version 0.6.0. Objects use the chosen installation schema; the old lexo schema was removed. superuser=false is not trusted=true. PGSTY patches lexo_next for native-type ordering and empty tables, and lexo_rebalance to preserve order independently of text collation.
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.6.0 | 1817161514 | pg_lexo | - |
| RPM | PIGSTY | 0.6.1 | 1817161514 | pg_lexo_$v | - |
| DEB | PIGSTY | 0.6.1 | 1817161514 | postgresql-$v-pg-lexo | - |
| OS / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 0.6.1 el8.x86_64.pg18 : pg_lexo_18 pg_lexo_18-0.6.1-1PGSTY.el8.x86_64.rpm
| PIGSTY 0.6.1 el8.x86_64.pg17 : pg_lexo_17 pg_lexo_17-0.6.1-1PGSTY.el8.x86_64.rpm
| PIGSTY 0.6.1 el8.x86_64.pg16 : pg_lexo_16 pg_lexo_16-0.6.1-1PGSTY.el8.x86_64.rpm
| N/A | N/A |
| el8.aarch64 | PIGSTY 0.6.1 el8.aarch64.pg18 : pg_lexo_18 pg_lexo_18-0.6.1-1PGSTY.el8.aarch64.rpm
| PIGSTY 0.6.1 el8.aarch64.pg17 : pg_lexo_17 pg_lexo_17-0.6.1-1PGSTY.el8.aarch64.rpm
| PIGSTY 0.6.1 el8.aarch64.pg16 : pg_lexo_16 pg_lexo_16-0.6.1-1PGSTY.el8.aarch64.rpm
| N/A | N/A |
| el9.x86_64 | PIGSTY 0.6.1 el9.x86_64.pg18 : pg_lexo_18 pg_lexo_18-0.6.1-1PGSTY.el9.x86_64.rpm
| PIGSTY 0.6.1 el9.x86_64.pg17 : pg_lexo_17 pg_lexo_17-0.6.1-1PGSTY.el9.x86_64.rpm
| PIGSTY 0.6.1 el9.x86_64.pg16 : pg_lexo_16 pg_lexo_16-0.6.1-1PGSTY.el9.x86_64.rpm
| N/A | N/A |
| el9.aarch64 | PIGSTY 0.6.1 el9.aarch64.pg18 : pg_lexo_18 pg_lexo_18-0.6.1-1PGSTY.el9.aarch64.rpm
| PIGSTY 0.6.1 el9.aarch64.pg17 : pg_lexo_17 pg_lexo_17-0.6.1-1PGSTY.el9.aarch64.rpm
| PIGSTY 0.6.1 el9.aarch64.pg16 : pg_lexo_16 pg_lexo_16-0.6.1-1PGSTY.el9.aarch64.rpm
| N/A | N/A |
| el10.x86_64 | PIGSTY 0.6.1 el10.x86_64.pg18 : pg_lexo_18 pg_lexo_18-0.6.1-1PGSTY.el10.x86_64.rpm
| PIGSTY 0.6.1 el10.x86_64.pg17 : pg_lexo_17 pg_lexo_17-0.6.1-1PGSTY.el10.x86_64.rpm
| PIGSTY 0.6.1 el10.x86_64.pg16 : pg_lexo_16 pg_lexo_16-0.6.1-1PGSTY.el10.x86_64.rpm
| N/A | N/A |
| el10.aarch64 | PIGSTY 0.6.1 el10.aarch64.pg18 : pg_lexo_18 pg_lexo_18-0.6.1-1PGSTY.el10.aarch64.rpm
| PIGSTY 0.6.1 el10.aarch64.pg17 : pg_lexo_17 pg_lexo_17-0.6.1-1PGSTY.el10.aarch64.rpm
| PIGSTY 0.6.1 el10.aarch64.pg16 : pg_lexo_16 pg_lexo_16-0.6.1-1PGSTY.el10.aarch64.rpm
| N/A | N/A |
| d12.x86_64 | PIGSTY 0.6.1 d12.x86_64.pg18 : postgresql-18-pg-lexo postgresql-18-pg-lexo_0.6.1-1PGSTY~bookworm_amd64.deb
| PIGSTY 0.6.1 d12.x86_64.pg17 : postgresql-17-pg-lexo postgresql-17-pg-lexo_0.6.1-1PGSTY~bookworm_amd64.deb
| PIGSTY 0.6.1 d12.x86_64.pg16 : postgresql-16-pg-lexo postgresql-16-pg-lexo_0.6.1-1PGSTY~bookworm_amd64.deb
| N/A | N/A |
| d12.aarch64 | PIGSTY 0.6.1 d12.aarch64.pg18 : postgresql-18-pg-lexo postgresql-18-pg-lexo_0.6.1-1PGSTY~bookworm_arm64.deb
| PIGSTY 0.6.1 d12.aarch64.pg17 : postgresql-17-pg-lexo postgresql-17-pg-lexo_0.6.1-1PGSTY~bookworm_arm64.deb
| PIGSTY 0.6.1 d12.aarch64.pg16 : postgresql-16-pg-lexo postgresql-16-pg-lexo_0.6.1-1PGSTY~bookworm_arm64.deb
| N/A | N/A |
| d13.x86_64 | PIGSTY 0.6.1 d13.x86_64.pg18 : postgresql-18-pg-lexo postgresql-18-pg-lexo_0.6.1-1PGSTY~trixie_amd64.deb
| PIGSTY 0.6.1 d13.x86_64.pg17 : postgresql-17-pg-lexo postgresql-17-pg-lexo_0.6.1-1PGSTY~trixie_amd64.deb
| PIGSTY 0.6.1 d13.x86_64.pg16 : postgresql-16-pg-lexo postgresql-16-pg-lexo_0.6.1-1PGSTY~trixie_amd64.deb
| N/A | N/A |
| d13.aarch64 | PIGSTY 0.6.1 d13.aarch64.pg18 : postgresql-18-pg-lexo postgresql-18-pg-lexo_0.6.1-1PGSTY~trixie_arm64.deb
| PIGSTY 0.6.1 d13.aarch64.pg17 : postgresql-17-pg-lexo postgresql-17-pg-lexo_0.6.1-1PGSTY~trixie_arm64.deb
| PIGSTY 0.6.1 d13.aarch64.pg16 : postgresql-16-pg-lexo postgresql-16-pg-lexo_0.6.1-1PGSTY~trixie_arm64.deb
| N/A | N/A |
| u22.x86_64 | PIGSTY 0.6.1 u22.x86_64.pg18 : postgresql-18-pg-lexo postgresql-18-pg-lexo_0.6.1-1PGSTY~jammy_amd64.deb
| PIGSTY 0.6.1 u22.x86_64.pg17 : postgresql-17-pg-lexo postgresql-17-pg-lexo_0.6.1-1PGSTY~jammy_amd64.deb
| PIGSTY 0.6.1 u22.x86_64.pg16 : postgresql-16-pg-lexo postgresql-16-pg-lexo_0.6.1-1PGSTY~jammy_amd64.deb
| N/A | N/A |
| u22.aarch64 | PIGSTY 0.6.1 u22.aarch64.pg18 : postgresql-18-pg-lexo postgresql-18-pg-lexo_0.6.1-1PGSTY~jammy_arm64.deb
| PIGSTY 0.6.1 u22.aarch64.pg17 : postgresql-17-pg-lexo postgresql-17-pg-lexo_0.6.1-1PGSTY~jammy_arm64.deb
| PIGSTY 0.6.1 u22.aarch64.pg16 : postgresql-16-pg-lexo postgresql-16-pg-lexo_0.6.1-1PGSTY~jammy_arm64.deb
| N/A | N/A |
| u24.x86_64 | PIGSTY 0.6.1 u24.x86_64.pg18 : postgresql-18-pg-lexo postgresql-18-pg-lexo_0.6.1-1PGSTY~noble_amd64.deb
| PIGSTY 0.6.1 u24.x86_64.pg17 : postgresql-17-pg-lexo postgresql-17-pg-lexo_0.6.1-1PGSTY~noble_amd64.deb
| PIGSTY 0.6.1 u24.x86_64.pg16 : postgresql-16-pg-lexo postgresql-16-pg-lexo_0.6.1-1PGSTY~noble_amd64.deb
| N/A | N/A |
| u24.aarch64 | PIGSTY 0.6.1 u24.aarch64.pg18 : postgresql-18-pg-lexo postgresql-18-pg-lexo_0.6.1-1PGSTY~noble_arm64.deb
| PIGSTY 0.6.1 u24.aarch64.pg17 : postgresql-17-pg-lexo postgresql-17-pg-lexo_0.6.1-1PGSTY~noble_arm64.deb
| PIGSTY 0.6.1 u24.aarch64.pg16 : postgresql-16-pg-lexo postgresql-16-pg-lexo_0.6.1-1PGSTY~noble_arm64.deb
| N/A | N/A |
| u26.x86_64 | PIGSTY 0.6.1 u26.x86_64.pg18 : postgresql-18-pg-lexo postgresql-18-pg-lexo_0.6.1-1PGSTY~resolute_amd64.deb
| PIGSTY 0.6.1 u26.x86_64.pg17 : postgresql-17-pg-lexo postgresql-17-pg-lexo_0.6.1-1PGSTY~resolute_amd64.deb
| PIGSTY 0.6.1 u26.x86_64.pg16 : postgresql-16-pg-lexo postgresql-16-pg-lexo_0.6.1-1PGSTY~resolute_amd64.deb
| N/A | N/A |
| u26.aarch64 | PIGSTY 0.6.1 u26.aarch64.pg18 : postgresql-18-pg-lexo postgresql-18-pg-lexo_0.6.1-1PGSTY~resolute_arm64.deb
| PIGSTY 0.6.1 u26.aarch64.pg17 : postgresql-17-pg-lexo postgresql-17-pg-lexo_0.6.1-1PGSTY~resolute_arm64.deb
| PIGSTY 0.6.1 u26.aarch64.pg16 : postgresql-16-pg-lexo postgresql-16-pg-lexo_0.6.1-1PGSTY~resolute_arm64.deb
| N/A | N/A |
Build
You can build the RPM / DEB packages for pg_lexo using pig build:
Install
You can install pg_lexo directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
Install the extension using pig or apt/yum/dnf:
Create Extension:
Usage
Sources:
pg_lexo 0.6.0 provides a Base62 lexo type for stable user-controlled ordering. It generates short values before, after, or between existing positions, allowing an item to move without renumbering every row. The type has comparison operators plus default B-tree and hash operator classes.
Core Workflow
lexo_first() starts at H. lexo_after(lexo), lexo_before(lexo), and lexo_between(lexo, lexo) generate neighboring positions; either argument to lexo_between may be NULL to represent an open end. Inputs contain only 0-9, A-Z, and a-z, whose ASCII order matches the type’s ordering.
Table Helpers
lexo_next(table, position_column, key_column, key_value) finds the current maximum and returns the next position, optionally within a group. lexo_add_column(table, column) adds a lexo column. lexo_rebalance(table, position_column, key_column, key_value) rewrites matching rows with evenly distributed positions and returns the number updated.
The helpers issue dynamic SQL and require the caller to have the corresponding table privileges. Rebalancing updates every selected row and should run with application writers coordinated. If positions have a unique constraint, use a deferrable constraint and defer it within the rebalancing transaction to allow intermediate values to overlap. Position generation itself does not reserve a value: concurrent sessions can derive the same position, so enforce a suitable unique constraint and retry or serialize conflicting moves. When no Base62 value exists between adjacent positions (or before the minimum), rebalance first.
Version 0.6 Boundary
Version 0.6 removed the dedicated lexo schema. The former lexo.lexorank type became lexo, and schema-qualified functions such as lexo.first() became names such as lexo_first(). Older examples are incompatible until migrated. Release/package 0.6.1 retains SQL/control version 0.6.0 and targets PostgreSQL 16–18 through pgrx 0.16.1. Pigsty packages patch lexo_next to use native ordering instead of the unavailable max(lexo) aggregate, and keep lexo_rebalance ordering independent of text collation.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)