Skip to main content
Citus transforms PostgreSQL into a distributed database with horizontal sharding. ParadeDB is fully compatible with Citus, enabling distributed full-text search across sharded tables.

What’s Supported

  • BM25 indexes on distributed tables — Create search indexes after distributing tables with create_distributed_table()
  • Distributed queries with search operators — Use the ||| (match disjunction) and &&& (match conjunction) operators in queries across sharded tables
  • Subqueries with LIMIT — Complex queries with subqueries and LIMIT clauses work correctly
  • JOIN queries — Search with JOINs across distributed tables

Installation

Both citus and pg_search must be added to shared_preload_libraries in the correct order:
The order in shared_preload_libraries matters. Always list citus before pg_search to ensure proper planner hook chaining.

Usage Example

Here’s a complete example of setting up distributed search with Citus:

Verify Distributed Execution

You can verify that both ParadeDB and Citus are working together by examining the query plan:
The plan should show:
  1. Citus Adaptive Custom Scan — Coordinating distributed query execution across shards
  2. ParadeDB Scan — Using the BM25 index within each shard
  3. Task Count: 32 — Query distributed across 32 shards (default Citus shard count)
ParadeDB search operators work seamlessly with Citus distributed JOINs:

Verify Distributed JOIN Execution

Check the execution plan for distributed JOINs with search:
Key indicators:
  • Nested Loop shows efficient JOIN execution on each shard
  • Custom Scan (ParadeDB Scan) on the outer side of the JOIN uses BM25 for filtering
  • Index Scan on authors table uses the primary key for lookups
  • JOINs execute locally on each shard for optimal performance

Known Limitations

  • Citus columnar tables — BM25 indexes and other PostgreSQL indexes (like GiST, GIN) cannot be created on Citus columnar tables due to limitations in Citus’s columnar storage implementation. However, you can use regular distributed tables with BM25 indexes alongside columnar tables for analytics.

Performance Considerations

When using ParadeDB with Citus:
  • Index creation happens locally on each shard, enabling parallel index building
  • Search queries execute in parallel across shards and results are merged by the coordinator
  • Distribution column should be chosen based on your query patterns to minimize cross-shard operations
For more guidance on optimizing distributed search workloads, please reach out to us in the ParadeDB Community Slack or via email.