Posts

Showing posts with the label citus

Scaling strategies

Image
Introduction Scaling strategies in PostgreSQL are methods that help the database handle larger volumes of data, support high user concurrency and maintain high performance. These strategies are divided into the following main groups: In-Database Scaling First, you should choose Data & Structure Optimization solutions right within the Database , which saves resources and avoids incurring costs associated with upgrading hardware or purchasing additional servers. Table Partitioning Divide a massive table (hundreds of millions of rows) into smaller tables by Range, List, or Hash . Example: Divide the orders table by month. Postgres only needs to scan the exact partition containing the required data (Partition Pruning). Indexing : Use the correct index types such as B-Tree (default), GIN (for JSONB/Full-text search) and BRIN (for large time-series data) to accelerate query speeds. Vacuuming : Configure optimized Autovacuum to clean up Dead Tuples , avoiding Table Bloat that inflates d...

Implementing Sharding with Citus

Image
Introduction In the era of big data, when storage capacity reaches the Terabyte threshold or the number of requests exceeds the physical limit of a single server ( Vertical Scaling / Scale-up ), Sharding is the optimal solution for Horizontal Scaling / Scale-out It is achieved by dividing a massive data table (billions of rows) into multiple small, independent and self-managed parts called Shards Each Shard is a separate physical database located on a different physical Server . The key point is that the data in the Shards does not overlap, but when combined, it forms a complete dataset. Horizontal Partitioning vs Sharding Horizontal Partitioning : Splitting a large table into smaller tables (such as by month) but all of these child tables still reside on the same physical server. Sharding : Distributing those child tables after partitioning across multiple different physical servers. Therefore, Sharding is the architecture of horizontal data partitioning in a distributed environ...