docs / quick-start
On this page
Quick start
A complete first session: install the engine, initialize, serve, create a multimodel table, write, query, index, and inspect.
Install nextsql and nextsqld first — see Install. Use two terminals. Paths below are examples. In production put the key file on a different volume from --data-dir.
Create a password file and initialize
What that does:
- Creates
/etc/nextsql/root.keyif it is missing (32-byte AES root, mode0600). - Creates a separate deployment registry root at
/etc/nextsql/root.key.instanceunless--instance-key-fileis supplied. - Creates the encrypted
nextsql.instanceregistry and/var/lib/nextsql/nextsql.dbwith their wrapped-key sidecars. - Bootstraps user
appwithADMINonCLUSTERandCONNECTon the default database.
Printed output includes the data-file path, database/file/deployment identity UUIDs, normalized realm name/ID, and logical default database name.
--user requires --password-file. The password file may end with a newline; it is stripped.
All init values can come from a protected host dotenv file. In particular, NEXTSQL_DATABASE=production automatically becomes the logical database name:
Run nextsql init --env-file /run/nextsql/hosting.env. Explicit flags override the file. Values are paths/names, never raw key bytes.
Existing pre-registry deployments must not be reinitialized. Stop nextsqld and run nextsql hosting adopt --data-dir /var/lib/nextsql --key-file /etc/nextsql/root.key --confirm. The offline command validates and recovery-opens the existing default database, preserves its identity/files, and does not discover sibling database files.
Start the server (loopback)
--user on nextsqld upserts that user if you want the server to create or refresh credentials at start. At least one user must exist or nextsqld refuses to start.
Loopback may run without TLS. Any bind that is not loopback requires --tls-cert and --tls-key. See TLS and client keys.
Run SQL from the CLI
nextsql exec is a one-shot client. After resolve, user, a password, and SQL are required. SQL is -c or a single positional argument.
Create the product table used throughout these docs:
VECTOR<F32,1536> is the production-shaped type. This walkthrough uses dimension 8 so you can type literals by hand. Dimension must match between the column, inserts, and NEAREST.
Insert two rows. JSON is a string literal that is parsed and stored as binary NSJB. Vectors are parenthesized floats. Points are POINT(lon, lat).
Successful DML prints affected N.
Query
Result columns are tab-separated.
Indexes
ANALYZE writes statistics the optimizer uses. EXPLAIN shows the chosen access path:
Full text, vectors, hybrid, geo
That hybrid statement is one physical plan: structured filters, BM25, and ANN share the same cost model and the same WAL / MVCC / encryption path.
Multi-statement transaction
nextsql exec sends one statement per invocation, so a BEGIN … COMMIT session needs a driver. From a Go session:
Without BEGIN, each statement is its own committed transaction.
Inspect the instance
diagnose reads plaintext headers only (no key). status --local also opens the database and prints table count, LSNs, isolated pages, query counters, and admission stats. Default status (no --local) dials nextsqld and prints mode server.