citus
citus · Distributed PostgreSQL as an extension
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 2400 | citus | citus | 15.0.0 | 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 |
| See Also | plproxy pgspider_ext postgres_fdw pg_partman timescaledb pg_ttl_index pgactive spock pg_fkpart db_migrator |
| Siblings | citus_columnar |
Packages
| Linux / PG | PG19 | PG18 | PG17 | PG16 | PG15 |
|---|---|---|---|---|---|
| el8.x86_64 | N/A | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 14.4.1 | PIGSTY 13.6.0 |
| el8.aarch64 | N/A | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 14.4.1 | PIGSTY 13.6.0 |
| el9.x86_64 | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 14.4.1 | PIGSTY 13.6.0 |
| el9.aarch64 | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 14.4.1 | PIGSTY 13.6.0 |
| el10.x86_64 | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 14.4.1 | PIGSTY 13.6.0 |
| el10.aarch64 | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 14.4.1 | PIGSTY 13.6.0 |
| d12.x86_64 | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 14.4.1 | PIGSTY 13.6.0 |
| d12.aarch64 | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 14.4.1 | PIGSTY 13.6.0 |
| d13.x86_64 | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 14.4.1 | PIGSTY 13.6.0 |
| d13.aarch64 | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 14.4.1 | PIGSTY 13.6.0 |
| u22.x86_64 | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 14.4.1 | PIGSTY 13.6.0 |
| u22.aarch64 | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 14.4.1 | PIGSTY 13.6.0 |
| u24.x86_64 | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 14.4.1 | PIGSTY 13.6.0 |
| u24.aarch64 | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 14.4.1 | PIGSTY 13.6.0 |
| u26.x86_64 | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 14.4.1 | PIGSTY 13.6.0 |
| u26.aarch64 | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 15.0.0 | PIGSTY 14.4.1 | PIGSTY 13.6.0 |
Source
github.com/citusdata/citus
citus-15.0.0.tar.gz
citus-14.4.1.tar.gz
citus-13.6.0.tar.gz
citus-12.1.18.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 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.
On PG17–19, Citus 15.0.0 uses SQL version 15.0-1. Preload citus on every node before a superuser runs CREATE EXTENSION.
| PostgreSQL | Package | citus SQL | citus_columnar SQL |
|---|---|---|---|
| 15 | 13.6.0 | 13.6-1 | 13.5-1 |
| 16 | 14.4.1 | 14.4-1 | 14.4-1 |
| 17–19 | 15.0.0 | 15.0-1 | 15.0-1 |
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
- PG15 and PG16 use the 13.x and 14.x maintenance branches shown above.
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.
14.3 and 14.4 Maintenance
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.
For the PG16 maintenance update from 14.3.0 to 14.4.1, install matching libraries and restart PostgreSQL on every node, then run this in each Citus database.
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.
Release 14.4.1
Release 14.4.1 restricts the citus_use_authinfo subscription option to superusers and preserves password verifiers during role propagation. Its maintenance upgrade script advances the SQL revision to 14.4-1.
15.0.0 and Existing Databases
15.0.0 supports distributed EXPLAIN IO on PG19. Single-shard fast-path queries can reuse worker plans with citus.enable_prepared_statement_caching.
On PG18, the packaged SQL files provide no in-place path from 14.3-1 to 15.0-1 for either extension. Check the installed revision and the available scripts in each existing database. A null path means the scripts cannot perform this transition.