citus
citus : Distributed PostgreSQL as an extension
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 2400 | citus | citus | 14.3-1 |
OLAP | AGPL-3.0-only | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --sLd-- | No | Yes | Yes | Yes | no | no |
| Relationships | |
|---|---|
| Schemas | pg_catalog |
| Need By | documentdb_distributed |
| See Also | plproxy pgspider_ext postgres_fdw pg_partman timescaledb pg_ttl_index pgactive spock pg_fkpart db_migrator |
| Siblings | citus_columnar |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 14.3-1 |
18 17 16 15 14 | citus |
- |
| RPM | PIGSTY | 14.3.0 |
18 17 16 15 14 | citus_$v |
- |
| DEB | PIGSTY | 14.3.0 |
18 17 16 15 14 | postgresql-$v-citus |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 13.5.0 | PGDG 13.0.0 |
| el8.aarch64 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 13.5.0 | PGDG 13.0.0 |
| el9.x86_64 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 13.5.0 | PGDG 13.0.0 |
| el9.aarch64 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 13.5.0 | PGDG 13.0.0 |
| el10.x86_64 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 13.5.0 | PIGSTY 13.0.0 |
| el10.aarch64 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 13.5.0 | PIGSTY 13.0.0 |
| d12.x86_64 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 13.5.0 | PIGSTY 13.0.0 |
| d12.aarch64 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 13.5.0 | PIGSTY 13.0.0 |
| d13.x86_64 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 13.5.0 | PIGSTY 13.0.0 |
| d13.aarch64 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 13.5.0 | PIGSTY 13.0.0 |
| u22.x86_64 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 13.5.0 | PIGSTY 13.0.0 |
| u22.aarch64 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 13.5.0 | PIGSTY 13.0.0 |
| u24.x86_64 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 13.5.0 | PIGSTY 13.0.0 |
| u24.aarch64 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 13.5.0 | PIGSTY 13.0.0 |
| u26.x86_64 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 13.5.0 | PIGSTY 13.0.0 |
| u26.aarch64 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 14.3.0 | PIGSTY 13.5.0 | PIGSTY 13.0.0 |
Source
github.com/citusdata/citus
citus-14.3.0.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Config this extension to shared_preload_libraries:
Create this extension with:
Usage
Sources:
- Citus v14.3.0 release
- Citus v14.3.0 CHANGELOG
- Citus v14.3.0 control file
- Citus v14.3.0 README
- What is Citus?
- Citus Utility Functions
- Citus upgrade procedure
Citus turns PostgreSQL into a distributed database by sharding tables across worker nodes while keeping PostgreSQL SQL, indexes, extensions, transactions, and operational tooling as the user-facing surface. It is commonly used for multi-tenant SaaS databases, real-time analytics, time-series/event workloads, and distributed microservice schemas.
The extension name is citus. Release 14.3.0 uses SQL/control version 14.3-1 and supports PostgreSQL 16-18. Every node must preload the library before a superuser runs CREATE EXTENSION; the extension is not relocatable.
Enable Citus
Preserve any other required preload libraries. Restart PostgreSQL on the coordinator and workers, then create the extension in each participating database:
On a multi-node cluster, register the coordinator and workers from the coordinator:
Distributed Tables
Distribute a table by a shard key. Rows with the same shard-key value are colocated on the same shard, so tenant-scoped joins and point lookups stay local.
Distribute the table and tune the shard count and colocation explicitly:
When choosing an explicit shard count, start a new colocation group with colocate_with := 'none'. To colocate with an existing distributed table, name that table and let its shard count determine the layout.
Queries that filter on the distribution column can route to a single shard:
Cross-shard queries are planned as distributed tasks and run in parallel on the workers:
Reference Tables
Reference tables are fully replicated to all workers. They are useful for small lookup tables that must join with many distributed tables.
Schema-Based Sharding
Schema-based sharding is useful when each tenant or service owns its own schema. Citus supports running schema-sharding DDLs from any node, including CREATE SCHEMA, DROP SCHEMA, ALTER SCHEMA RENAME, ALTER SCHEMA OWNER, and table-level DDL on distributed schemas.
Use row-based distribution for shared tables and schema-based sharding for per-tenant schema layouts; do not mix the two models casually without checking colocation and SQL-support implications.
Node and Shard Operations
Backup Coordination
Citus v14.1.0 adds UDFs for blocking distributed 2PC commit decisions and schema/topology changes while taking coordinated disk snapshots. Use them only inside a controlled backup workflow, and always unblock the cluster after the snapshot step.
Pair these functions with regular PostgreSQL backup discipline: consistent checkpoints, WAL archiving, snapshot ordering across nodes, and a tested restore procedure.
Administrative Controls
Citus 14.2 adds the superuser-only citus_internal.distribute_object() repair helper for supported database objects whose metadata was not propagated correctly. Treat it as a targeted recovery operation, not as the normal distribution API.
The release also adds citus.allow_unsafe_insert_select_pushdown for explicitly opting into batched INSERT ... SELECT pushdown on colocated tables, and improves single-shard stored-procedure execution. Keep the unsafe pushdown setting off unless the workload has been checked against the release-note restrictions.
Caveats
- Citus 14 supports PostgreSQL 16-18 and dropped PostgreSQL 15 support.
shared_preload_libraries = 'citus'must be set before extension creation. A plainCREATE EXTENSION citusis not enough on a fresh server.- Choose the distribution column carefully. Primary keys and unique constraints on distributed tables generally need to include the distribution column.
- Cross-shard joins, repartition joins, distributed DDL, and multi-shard writes are powerful but have different planning and locking behavior from single-node PostgreSQL.
- The distribution also provides
citus_columnar; its storage and maintenance requirements are separate from distributing row tables. - The cluster-change blocking functions are operational tools for backups. Do not leave a cluster blocked after a failed backup script.
Release 14.3 and Upgrades
Release 14.3.0 merges sorted worker results for multi-shard ORDER BY queries and fetches rows in smaller batches where possible. It adds citus.enable_or_clause_arm_pruning to prune irrelevant OR-clause arms per shard. It also restricts internal metadata cleanup to superusers, uses an empty search path for internal SPI queries, and replays object definitions under their owner’s restricted execution context.
Coordinate the upgrade across all nodes. After installing matching binaries and restarting PostgreSQL, run the SQL update in each database containing Citus:
Finish the cluster upgrade on the coordinator:
Use the SQL/control version in ALTER EXTENSION, not the package version. If both Citus and PostgreSQL need upgrading, complete the Citus upgrade first and follow the separate PostgreSQL-major upgrade procedure.