Terminal
Terminal/Skill
Tips for speeding up SurrealDB queries through record ID design, index choice, EXPLAIN checks, and precomputed fields.
By SurrealDB
Works with
npx skills add surrealdb/agent-skills --skill surrealql-performanceTechniques for making SurrealDB queries fast: structuring record IDs and keys for data locality, choosing and verifying the right indexes, and precomputing values with computed fields and views instead of recomputing them on every read.
Target the latest stable SurrealDB release. Confirm version-sensitive syntax
(record ranges, COMPUTED fields, FULLTEXT index options) against
https://surrealdb.com/docs, and validate examples with surreal validate. See
the surrealql skill for version detection.
UNIQUE, full-text SEARCH, or vector indexesEXPLAIN)| Topic | Reference |
|---|---|
| Record ID & key structuring for locality and range scans | references/keys.md |
| Index types, composite order, verifying usage, rebuild cost | references/indexing.md |
| Computed fields, precomputed views, event-maintained values | references/computed-fields.md |
weather:['London', d'2025-02-13T05:00Z']) so related records sit together and
range queries avoid full-table scans. See references/keys.md.WHERE on the ID. SELECT * FROM person:1..1000
uses key ordering directly; filtering with WHERE after a full scan does not.EXPLAIN (or EXPLAIN FULL) to confirm a query
uses the index you expect before concluding it is optimized.DEFINE TABLE ... AS SELECT view, or a DEFINE EVENT to maintain derived data
rather than recomputing aggregates on every query. See
references/computed-fields.md.