citus
citus : Distributed PostgreSQL as an extension
Overview
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --sLd-- | No | Yes | Yes | Yes | no | no |
| Relationships | |
|---|---|
| Schemas | pg_catalog |
| Need By | cigration 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.2.0 |
18 17 16 15 14 | citus |
- |
| RPM | PIGSTY | 14.2.0 |
18 17 16 15 14 | citus_$v |
- |
| DEB | PIGSTY | 14.2.0 |
18 17 16 15 14 | postgresql-$v-citus |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PGDG 14.2.0 | PGDG 14.2.0 | PGDG 14.2.0 | PGDG 13.2.0 | PGDG 13.0.0 |
| el8.aarch64 | PGDG 14.2.0 | PGDG 14.2.0 | PGDG 14.2.0 | PGDG 13.2.0 | PGDG 13.0.0 |
| el9.x86_64 | PGDG 14.2.0 | PGDG 14.2.0 | PGDG 14.2.0 | PGDG 13.2.0 | PGDG 13.0.0 |
| el9.aarch64 | PGDG 14.2.0 | PGDG 14.2.0 | PGDG 14.2.0 | PGDG 13.2.0 | PGDG 13.0.0 |
| el10.x86_64 | PGDG 14.2.0 | PGDG 14.2.0 | PGDG 14.2.0 | PGDG 13.2.0 | PIGSTY 13.0.0 |
| el10.aarch64 | PGDG 14.2.0 | PGDG 14.2.0 | PGDG 14.2.0 | PGDG 13.2.0 | PIGSTY 13.0.0 |
| d12.x86_64 | PIGSTY 14.2.0 | PIGSTY 14.2.0 | PIGSTY 14.2.0 | PIGSTY 13.2.0 | PIGSTY 13.0.0 |
| d12.aarch64 | PIGSTY 14.2.0 | PIGSTY 14.2.0 | PIGSTY 14.2.0 | PIGSTY 13.2.0 | PIGSTY 13.0.0 |
| d13.x86_64 | PIGSTY 14.2.0 | PIGSTY 14.2.0 | PIGSTY 14.2.0 | PIGSTY 13.2.0 | PIGSTY 13.0.0 |
| d13.aarch64 | PIGSTY 14.2.0 | PIGSTY 14.2.0 | PIGSTY 14.2.0 | PIGSTY 13.2.0 | PIGSTY 13.0.0 |
| u22.x86_64 | PIGSTY 14.2.0 | PIGSTY 14.2.0 | PIGSTY 14.2.0 | PIGSTY 13.2.0 | PIGSTY 13.0.0 |
| u22.aarch64 | PIGSTY 14.2.0 | PIGSTY 14.2.0 | PIGSTY 14.2.0 | PIGSTY 13.2.0 | PIGSTY 13.0.0 |
| u24.x86_64 | PIGSTY 14.2.0 | PIGSTY 14.2.0 | PIGSTY 14.2.0 | PIGSTY 13.2.0 | PIGSTY 13.0.0 |
| u24.aarch64 | PIGSTY 14.2.0 | PIGSTY 14.2.0 | PIGSTY 14.2.0 | PIGSTY 13.2.0 | PIGSTY 13.0.0 |
| u26.x86_64 | PIGSTY 14.2.0 | PIGSTY 14.2.0 | PIGSTY 14.2.0 | PIGSTY 13.2.0 | PIGSTY 13.0.0 |
| u26.aarch64 | PIGSTY 14.2.0 | PIGSTY 14.2.0 | PIGSTY 14.2.0 | PIGSTY 13.2.0 | PIGSTY 13.0.0 |
Source
github.com/citusdata/citus
citus-14.2.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.2.0 release
- Citus v14.2.0 CHANGELOG
- Citus v14.2.0 control file
- What is Citus?
- Citus Utility Functions
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 local Pigsty catalog packages Citus as citus and exposes the lead extension citus; the same package also contains citus_columnar. Citus is a preload extension, so every node must load the library before CREATE EXTENSION.
Enable Citus
Restart PostgreSQL on the coordinator and workers, then create the extension in the 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.
Version 14.2 Operations
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
- Pigsty local metadata currently tracks Citus 14.x for PostgreSQL 16-18; Citus 14 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.
- Citus includes its own columnar storage surface through
citus_columnar; Pigsty metadata marks it as conflicting with Hydracolumnar. - The cluster-change blocking functions are operational tools for backups. Do not leave a cluster blocked after a failed backup script.