file-json-db

Performance & Limits

file-json-db is an embedded, file-based database. It shines for small-to-medium datasets and low-to-moderate concurrency. This page describes realistic expectations and how to stay fast.

What it is good at

What it is not designed for

Indexes make a big difference

A findOne on an indexed field only loads the part that contains the document. A full-collection scan without an index reads every part.

// Fast – uses secondary index
users.findOne({ email: 'alice@example.com' });

// Slower – full scan
users.find({ age: { $gte: 30 } }).toArray();

Index every field you frequently look up by exact value (email, username, sku, status, foreign keys, …).

Part size tuning

const logs = db.collection({
  name: 'logs',
  maxPartSize: 512 * 1024,
  maxRecords: 2000
});

Memory

At any moment a collection keeps in memory:

Parts that are not needed are not kept. Memory therefore grows mainly with the size of the indexes, not with the total size of all part files.

Concurrency model

Async methods on the same collection are serialized through an in-process lock. Multiple processes writing the same collection concurrently are not safe. For multi-process scenarios use a proper database server or external locking.

Practical tips