# Galactus DB 2.2.0: the whole map of Great Britain in a 4 GB container

We loaded every road, building, wood, river and place name in Great Britain into
Galactus DB 2.2.0, running in a container capped at 4 GB of memory. That is 16.1
million shapes from Ordnance Survey's VectorMap District, 12 GB of shapefiles. The
load took six minutes and never used more than 1.7 GB. A map viewer now draws it
straight from the spatial indexes, from a single street to the whole country, at
2 ms per tile.

## What we loaded

OS VectorMap District is Ordnance Survey's open map of Great Britain, published as
ESRI shapefiles in 55 folders of 100 km grid squares. It has 21 layers: buildings,
roads, woodland, rivers and lakes, the coast, railways, administrative boundaries,
place names and more.

| | |
|---|---|
| Shapefiles | 945 files, 12.2 GB extracted (2.6 GB zipped) |
| Features | 16,134,472 |
| Vertices | 282.6 million |
| Coordinates | British National Grid eastings and northings, in metres |

![The Lake District at 12 m per pixel: every stream, tarn, wood and fell name, drawn from Galactus DB](/blog/charts/vmd-lakes.jpg)

Each layer became a label with its own spatial index, and main roads got a second
label so the national view can draw the trunk network on its own. That makes 22
spatial indexes in all. The shapes are stored as cartesian geometry in metres,
exactly as they appear in the files.

## Six minutes to load

We wrote the importer in Rust. It reads the `.shp` and `.dbf` files itself and
sends the shapes to Galactus over Bolt as well-known binary, in batches of 2,000,
on four connections. Polygons with several parts become a shape per part, and the
largest coastlines and forests are cut into pieces of about a thousand vertices,
which keeps every map tile small. The indexes were created first and kept up to
date as the rows arrived.

- **360 seconds** for all 16.1 million features, written as 16.2 million shapes.
- **44,900 shapes a second** on average, 4.5 GB of geometry in all.
- **Every shape accepted:** Galactus validated all 16.2 million and rejected none.

Keeping 22 indexes up to date during the load costs about a sixth of the time. One
100 km square around Stoke-on-Trent and Shropshire, 733,017 shapes, loads in 13.7 s
with its indexes and 11.4 s without them.

![Seconds to load one 100 km square with and without its spatial indexes](/blog/charts/vmd-load.svg)

## 1.7 GB at the busiest moment

The container had a hard 4 GB limit and no swap. Galactus started at 26 MB and
averaged 1.2 GB while it loaded. The highest reading, near the end of the load, was
1.7 GB. Galactus sized its own page cache at 1 GB, half of
its default memory budget, and stayed inside it.

![Container memory before and while loading, against the 4 GB limit](/blog/charts/vmd-memory.svg)

## Smaller than the files it came from

With all 22 spatial indexes, the database takes 9.5 GB on disk, against 12.2 GB for
the shapefiles it was loaded from.

![Size on disk of the shapefiles and of the Galactus DB database](/blog/charts/vmd-disk.svg)

## A map that keeps up

The viewer is a desktop app, written in Rust like the importer. It cuts each layer
into square tiles of the British National Grid, from 2 km for buildings to 64 km for
the sea, and fetches each tile with one call:

```cypher
CALL db.index.spatial.intersects('vmd_building',
  spatial.fromWKT('POLYGON((330000 330000,332000 330000,332000 332000,330000 332000,330000 330000))'))
YIELD node
RETURN node.shape
```

Eight connections fetch the tiles nearest the centre of the screen first. The
viewer keeps fetched tiles on the graphics card, so panning and zooming never wait
for the database.

![Stoke-on-Trent at 3 m per pixel: buildings, roads by class, rivers and woodland](/blog/charts/vmd-stoke.jpg)

![Westminster and St James's Park at 1.2 m per pixel](/blog/charts/vmd-westminster.jpg)

Its demo mode flies from place to place on its own, and the panel shows what
Galactus is doing as it goes: tile queries in the last five seconds, their median
and 95th percentile, shapes on screen and the database's own page cache.

![The viewer in demo mode with its live statistics panel](/blog/charts/vmd-demo-panel.jpg)

We flew it twice round twelve places, from the Welsh border to Westminster, Skye and
the whole of Great Britain, holding each one for a few seconds:

- **34,069 tile queries**, median **2.1 ms**, 95th percentile 42 ms, 99th 76 ms.
- At every stop, every tile on screen had arrived before the viewer moved on, from
  0.6 m per pixel in Westminster to 900 m per pixel for the whole country.
- The full national view, 366,352 shapes of motorways, main roads and coast, drew
  from a cold start within 12 seconds.
- 121 frames a second throughout, the display's own refresh rate.

![Tile query latency from the viewer, and single-tile medians by layer](/blog/charts/vmd-tiles.svg)

## What changed in 2.2.0

The [shape index](/docs/indexes/spatial#shape-index) is now a multi-level grid. Each
shape is filed once, in the grid cell sized to fit it, and a query reads only the
cells around its own outline. A query's cost follows the shapes near it, however
large the map grows. The cell sizes come from the coordinates, so metres, feet and
degrees all work without configuration.

- **Geography.** Shapes in longitude and latitude are indexed by envelopes that
  follow great-circle edges: the bulge of a long edge towards the pole, shapes that
  cross the 180th meridian, and polygons around a pole.
- **Rectangles.** A rectangular query, such as a map tile, accepts every shape that
  lies wholly inside it without decoding its geometry.
- **Deletes.** Deleting, moving or relabelling a shape removes its index entries,
  and `CALL gdb.compact()` gives the space back.
- **Upgrading.** A database from 2.0 or later rebuilds its shape indexes in the new
  layout the first time 2.2.0 opens it.

Galactus DB 2.2.0 is on Docker Hub now as `ianknowles/galactus-db:2.2.0` and
`latest`, for Linux AMD64 and ARM64.

## How we measured

- **Galactus DB:** 2.2.0 with Paged storage and its shipped settings, including
  buffered durability with a 50 ms commit-log sync. The container was limited to
  4 GB of memory with no swap and no CPU limit.
- **Host:** Intel Core i9-13900K with 64 GB of RAM and a Samsung 990 PRO NVMe drive,
  running Windows 11 Pro and Docker Desktop 28.0.1 on WSL 2.
- **Clients:** the importer and the viewer ran on the same machine and used the
  Galactus Rust driver 0.2.0 over Bolt 5.4.
- **Memory** is the container's usage from `docker stats`, sampled every 30 seconds.
  **Disk** is the size of the database's Docker volume.
- **Query times** run from sending the query to the driver handing back the last
  record, measured in the viewer. Turning the shapes into triangles and drawing them
  comes after.

Contains OS data © Crown copyright and database right 2026.
