Home▸Algorithms & AI▸Query Optimizer: Join-Order Cost Search

🧪 Query Optimizer: Join-Order Cost Search

This simulation demonstrates techniques for optimizing database performance through indexing, query optimization, and data modeling strategies.

Algorithms & AI3DModerate60 FPS📱 Mobile-adapted🟠 Blender⇄ 2D version
Query Optimizer: Join-Order Cost Search ↗ Open standalone

Behind every multi-table SQL query, the database's cost-based optimizer has to pick which order to join the tables in — the same result set can cost 100× more or less depending on the order chosen. This simulation runs the real dynamic-programming algorithm that engines like PostgreSQL use (in the spirit of IBM's System R optimizer): it solves every subset of the query's tables exactly once, caching the cheapest way to build each subset from smaller pieces, and reconstructs the winning plan as a 3D join tree. Switch between a nested-loop and a hash-join cost model to see how the optimal order changes, and compare it against a naive left-deep plan that just joins tables in the order they were written to see exactly what a real optimizer buys you.

⚙ Under the hood

This simulation demonstrates techniques for optimizing database performance through indexing, query optimization, and data modeling strategies.

Three.jsDatabase OptimizationAlgorithmQuery PlannerDynamic ProgrammingJoin Ordering

3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)