Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Local database

The builder does not parse SQL dumps itself. It loads them into a local MariaDB server, then queries the tables. The dev shell provides the server and three scripts to manage it.

Scripts

ScriptWhat it does
db-startCreates the data directory on first run, starts the server, creates the wikipedia database
db-stopStops the server
db-resetStops the server, deletes all data, starts a fresh server

Open a SQL shell with:

mariadb wikipedia

Where the data lives

  • Data directory: $WPATH_DB_DIR/data, which is .mariadb/data in the repository.
  • Socket: $WPATH_DB_DIR/mariadb.sock. The server does not listen on TCP.
  • Log: $WPATH_DB_DIR/mariadb.log.

.mariadb/ is in .gitignore.

Settings

The server is tuned for bulk loading of data you can download again. It gives up durability for speed: no binary log, no doublewrite buffer, and the log is not flushed on each commit. If the machine crashes during provision, run provision again.

VariableDefaultEffect
WPATH_DB_BUFFER_POOL8GInnoDB buffer pool size
WPATH_DB_NAMEwikipediaDatabase created by db-start and used by provision and build

Set them before db-start, for example WPATH_DB_BUFFER_POOL=16G db-start. The buffer pool size applies each time the server starts.

Be careful with db-reset

db-reset deletes every loaded table. Loading them again with provision takes hours. Only run it when you really want an empty database.

Read-only access from build

build never writes to the database. Each query runs in a session opened with SET SESSION TRANSACTION READ ONLY, and the builder checks @@session.transaction_read_only before it reads any row. If the check fails, the build stops.