Home▸Algorithms & AI▸Space-Filling Curve Range Queries: Hilbert versus Z-Order Cluster Counts

Space-Filling Curve Range Queries: Hilbert versus Z-Order Cluster Counts

A database stores a two-dimensional grid of records in one-dimensional order along a space-filling curve. A rectangular range query then touches the records in several separate runs, and every run costs a disk seek. Slide a query rectangle across a grid ordered by the Hilbert curve and by the Z-order (Morton) curve and count the runs: Hilbert needs about the half-perimeter divided by two runs, Z-order needs noticeably more. Change grid size, window width, window height and the seek cost and watch the total access cost. A Blender-built storage board with numerical checks.

Algorithms & AI3DModerate60 FPS📱 Mobile-adapted🟠 Blender⇄ 2D version
Space-Filling Curve Range Queries: Hilbert versus Z-Order Cluster Counts ↗ Open standalone

A database stores a two-dimensional grid of records in one-dimensional order along a space-filling curve. A rectangular range query then touches the records in several separate runs, and every run costs a disk seek. Slide a query rectangle across a grid ordered by the Hilbert curve and by the Z-order (Morton) curve and count the runs: Hilbert needs about the half-perimeter divided by two runs, Z-order needs noticeably more. Change grid size, window width, window height and the seek cost and watch the total access cost. A Blender-built storage board with numerical checks.

⚙ Under the hood

A database stores a two-dimensional grid of records in one-dimensional order along a space-filling curve. A rectangular range query then touches the records in several separate runs, and every run costs a disk seek. Slide a query rectangle across a grid ordered by the Hilbert curve and by the Z-order (Morton) curve and count the runs: Hilbert needs about the half-perimeter divided by two runs, Z-order needs noticeably more. Change grid size, window width, window height and the seek cost and watch the total access cost. A Blender-built storage board with numerical checks.

Space-Filling CurveHilbert CurveZ-Order CurveMorton CodeRange QuerySpatial IndexDatabase Locality

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

What did you find?

Add reproduction steps (optional)