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
Bothcitus 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:- Citus Adaptive Custom Scan — Coordinating distributed query execution across shards
- ParadeDB Scan — Using the BM25 index within each shard
- Task Count: 32 — Query distributed across 32 shards (default Citus shard count)
Example EXPLAIN Output
Example EXPLAIN Output
Distributed JOINs with Search
ParadeDB search operators work seamlessly with Citus distributed JOINs:Verify Distributed JOIN Execution
Check the execution plan for distributed JOINs with search:Example EXPLAIN Output for JOIN
Example EXPLAIN Output for JOIN
Nested Loopshows efficient JOIN execution on each shardCustom Scan (ParadeDB Scan)on the outer side of the JOIN uses BM25 for filteringIndex Scanon 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