Citus is a distributed database that scales out Postgres. By using the extension APIs, Citus distributes your tables across a cluster of machines and parallelizes SQL queries. This talk describes Citus' distributed query planner by focusing on our experience in distributed systems. We first show that the primary challenge for any distributed planner is a theoretical understanding of which computations are easy to scale. We provide three example SQL queries that demonstrate these challenges: (a) simpler aggregate functions with groupings, (b) large table joins, and (c) complex subselects. We then explain why some queries are harder to scale than others. Next, we map these two queries into relational algebra (logical plan). We show that a simple abstraction, one that separates logical and physical planning, can minimize network I/O and parallelize all SQL queries in a small amount of code. We conclude by comparing query planning methods across different distributed databases. |