# Nearing the theoretical limit: Galactus DB 2.4.3

There is a speed no database can beat: the speed of the work itself, with
nothing wasted on the way. For a database that keeps its graph on disk, that
speed is easy to find, because we ship it too: the same graph held entirely
in memory. In Galactus DB 2.4.3 the two have met. A graph read from pages on
disk scans 100,000 people in **8.3 ms where it took 26.2**, exactly as long as
the engine that keeps everything in memory.

![Median latency over Bolt on Galactus DB 2.1.8 and 2.4.3, Paged and Resident engines](/blog/charts/release-243-bolt.svg)

## Which limit?

"Theoretical limit" is a grand phrase for a blog post, so here is the one we
mean.

Galactus DB has two engines. Paged, the default, keeps the graph on disk in
checksummed 8 KiB pages and holds the pages in use in memory, so a graph can
be far larger than the machine it runs on. Resident holds the whole graph in
memory and never fetches anything. They run the same queries through the same
code and give the same answers, so Resident's time is what the work costs
when storage costs nothing at all.

That is the limit. The quickest a database of pages can ever be is as quick
as a database with no pages.

## As quick as memory

This is [the benchmark we published](/blog/galactus-db-open-benchmark) on
2.1.8, run again on 2.4.3 on the same machine with the same limits.

| 8 CPUs, 4 GB, median | Paged 2.1.8 | Paged 2.4.3 | Resident 2.4.3 |
|---|---:|---:|---:|
| Index lookup by id | 0.50 ms | 0.48 ms | 0.47 ms |
| Friends of friends | 0.53 ms | 0.48 ms | 0.48 ms |
| Filtered scan of 100,000 people | 26.2 ms | **8.3 ms** | 8.3 ms |
| Shortest path, up to 6 hops | 0.62 ms | 0.52 ms | 0.48 ms |
| All shortest paths, up to 6 hops | 0.59 ms | 0.54 ms | 0.51 ms |
| Weighted shortest path (Dijkstra) | 23.6 ms | 23.1 ms | 22.9 ms |
| Index lookups, 16 clients, reads/s | 4,108 | 4,103 | 4,117 |

On 2.1.8 the scan was the one query where you could tell which engine you
were on: Paged took three times as long. On 2.4.3 both take 8.3 ms, and every
other row has edged down as well. Paged does it in 169 MB with the graph
loaded, and still opens straight from disk: 0.76 s from starting the
container to the first correct answer.

Give it a quarter of the machine, 2 CPUs and 1 GB, and Paged's scan drops
from 30.1 ms to 12.4 ms, with lookups, traversals and unweighted paths all
between 0.48 ms and 0.55 ms.

The engine built for graphs far larger than memory now keeps pace with the
one that holds everything in memory.

## Four millionths of a second

Those times include the trip: out of your application, through the driver,
across the network and back again. Stand inside the engine with a stopwatch
and the numbers get smaller still. On the Paged engine, with one query
worker and a graph of 100,000 nodes and 1.2 million relationships:

- **Finding a node by an indexed property takes 4.0 microseconds.** Light
  covers about 1.2 km in that time.
- **Two hops out from a node and a count of what is there: 15 microseconds.**
  Three hops: 79.
- **Walking every relationship of every node takes 79.5 ms**, which is 66
  nanoseconds a relationship, 1.2 million times in a row.
- **A shortest path from one side of the graph to the other: 4.0 ms.**
- **A filtered scan of all 100,000 nodes: 15.2 ms**, or 3.9 ms when eight
  workers share it. That is 39 nanoseconds a node.

So of the 0.48 ms a lookup takes over Bolt, the engine's own share is less
than a hundredth. The rest is travel.

Run the in-memory engine beside it in the same process and Paged walks those
1.2 million relationships within 14% of it, and returns every node in the
graph within 8%.

## How we got here

No single trick did this. We asked the same question of every query, release
after release: what is it doing that the answer does not need?

### 2.1.8 to 2.3.0: stop early, read less

- **Weighted paths stop at the target.** `gds.shortestPath.dijkstra` with one
  target used to settle every reachable node before reading off one path. On
  a 100,000-node graph the call went from 105 ms to 24 ms.
- **Spatial searches read only the area they cover.** With the
  [16.1 million shapes of Great Britain](/blog/galactus-db-2-2-great-britain-in-4-gb)
  loaded, a 2 km tile of buildings or roads comes back in about 2 ms. Point
  searches and `ORDER BY … LIMIT` over a range index stop as soon as they
  have their rows.
- **SQL reads tables directly.** On one node's 200,000-row table, `count(*)`
  went from 161 ms to 0.02 ms, an indexed `ORDER BY … DESC LIMIT 10` from
  249 ms to 0.1 ms, and a one-row `UPDATE` by key from 239 ms to 0.05 ms.

### 2.4.1: stop reading what nobody asked for

`id(n)`, `labels(n)`, `type(r)`, `n:Label` and `a = b` are questions about
what an element is, and the engine used to load everything the element owns
before answering. It was like fetching someone's whole filing cabinet to
check the name on the drawer. Now it reads the label.

- `sum(id(n))` over 100,000 nodes: 215 ms to 12 ms.
- `count(DISTINCT m)` over two hops compares identities: 260 µs to 22.5 µs.
- `AND` and `OR` stop when the left side has decided: a three-condition
  filter over a label went from 79 ms to 50 ms.
- Returning a node reads its properties in one pass: `MATCH (n:P) RETURN n`
  went from 220 ms to 80 ms.

### 2.4.2: stop walking where the answer cannot be

- **A filter is tested as soon as its variables are bound.** In `MATCH
  (a:P)-[:KNOWS]->(b) WHERE a.group = 3`, a node outside group 3 used to have
  all its relationships walked before it was thrown away. 349 ms to 53 ms. A
  filter on the second node of a three-hop pattern: 358 µs to 10.9 µs.
- **`shortestPath` searches by node.** The work no longer grows with the
  number of paths between the two ends. A path across the graph went from
  38 ms to 3.9 ms, with 16,600 allocations where there were 368,000.
- **An expansion reads a relationship's type and far end from the node it
  starts at**, where it used to open each relationship's own record. Every
  relationship of every node: 116 ms to 80 ms.

### 2.4.3: stop queueing for the catalogue

When we [introduced the Paged engine](/blog/galactus-db-2-0-project-orion) we
called it a library: the books you are reading are open on your desk and the
rest are on the shelves. We left out the catalogue. To find the shelf holding
a page of properties, every reader walked the catalogue from the top drawer
down, and held each drawer shut against the others while they looked. One
reader never noticed. Eight readers scanning the same graph spent their time
waiting at the drawers.

In 2.4.3 each reader is handed the bottom drawer's list when the database
opens. Finding a page is reading one line of it, with nobody to wait for. A
write that changes part of the graph reprints only the lines that changed.
Where the memory you already gave the database has room, the property pages
themselves stay on the desk.

- A label scan with an equality filter, inside the engine: 28.9 ms to 15.2 ms
  with one query worker, and **26.4 ms to 3.9 ms with eight**.
- Three conditions joined by `AND`: 49.4 ms to 26.0 ms, and 46.6 ms to 6.7 ms
  with eight workers.
- A range seek returning rows: 1.17 ms to 0.61 ms.
- Writes got lighter too. Creating 5,000 nodes in one statement went from
  30.2 ms to 25.7 ms, with 12 fewer allocations for each row.

Put together, on the Paged engine with one query worker:

![Milliseconds for one statement before each change and on 2.4.3](/blog/charts/release-243-steps.svg)

| Statement | Before | 2.4.3 | Changed in |
|---|---:|---:|---|
| `sum(id(n))` over every node | 215 ms | 11.5 ms | 2.4.1 |
| Return every node | 220 ms | 64.6 ms | 2.4.1, 2.4.3 |
| One hop, filter on the first node | 349 ms | 37.7 ms | 2.4.2, 2.4.3 |
| Three conditions joined by `AND` | 79 ms | 26.0 ms | 2.4.1, 2.4.3 |
| Shortest path across the graph | 38.3 ms | 4.0 ms | 2.4.2 |
| Every relationship of every node | 116 ms | 79.5 ms | 2.4.2 |

## What it asks of you

Nothing. There is no new syntax and no setting to change, and 2.4.1, 2.4.2
and 2.4.3 leave the files on disk exactly as 2.4.0 wrote them.

The property pages that now stay in memory come out of the budget each
database already had (`GDB_PIN_BYTES`, 256 MiB by default), which is itself
part of the page cache. The memory limit you set is the memory limit you get.
A database whose properties do not fit that budget gains from the catalogue
all the same: with the budget cut to 4 MiB, the scan above was 18% faster
with one worker and 57% faster with eight.

## How we measured

- **Over Bolt:** the open
  [graph database benchmark](https://github.com/galactusdb/galactus-db-benchmark),
  with the published Galactus DB 2.4.3 image (`sha256:8d8ba72b…`) on its
  shipped settings, including buffered durability with a 50 ms commit-log
  sync. Each engine ran alone in a container limited to 8 CPUs and 4 GB, on a
  fresh volume, and every figure is the median of three passes. The graph is
  100,000 people who each know two others. The client was Python 3.10 with
  the Neo4j Python driver 5.28.1. The 2.1.8 figures are from the same suite
  on the same machine on 01/11/2026.
- **Inside the engine:** release builds of each version, run natively and
  pinned to the machine's performance cores, on a graph of 100,000 nodes and
  1,200,000 relationships. Each figure is the fastest of five rounds, with
  one query worker unless eight are named. Each release was measured against
  the one before it; in the table, "Before" is the release ahead of the
  first change named.
- **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.

## Get it

```text
docker pull ianknowles/galactus-db:2.4.3
```

It is also `latest`, for Linux AMD64 and ARM64. For the same figures beside
other databases, see [Galactus DB compared with Neo4j](/compare/neo4j) and
[Galactus DB compared with Memgraph](/compare/memgraph).

Three releases in two days, and each one made the database do less. We are
told that is not how software usually goes.
