Show Menu
Cheatography

SurrealQL Cheat Sheet (DRAFT) by

SurrealQL is the query language for SurrealDB. SurrealQL is a powerful and intuitive database query language that closely resembles traditional SQL but comes with unique differences and improvements.

This is a draft cheat sheet. It is a work in progress and is not finished yet.

M-Tree Index

DIMENSION
   
Size of the vector
DIST
EUCLIDEAN
EUCLIDEAN, COSINE, MANHATTAN
Distance function
TYPE
F64
F64, F32, I64, I32, I16
Vector type
CAPACITY
40
 
Max number of records that can be stored in the index
DOC_ID­S_ORDER
100
DOC_ID­S_CACHE
100
MTREE_­CACHE
100
-- Defaults:
DEFINE INDEX mt_idx ON pts FIELDS point MTREE DIMENSION 3;
-- Explicit:
DEFINE INDEX mt_idx ON pts FIELDS point MTREE DIMENSION 3 DIST EUCLIDEAN TYPE F64 CAPACITY 40 DOC_ID­S_ORDER 100 DOC_ID­S_CACHE 100 MTREE_­CACHE 100;

HNSW Index

DIMENSION
   
Size of the vector
DIST
EUCLIDEAN
EUCLIDEAN, COSINE, MANHATTAN
Distance function
TYPE
F64
F64, F32, I64, I32, I16
Vector type
EFC
150
 
EF constr­uction
M
12
 
max connec­tions per element
M0
24
 
max connec­tions in the lowest
LM
0.4024­296­043­818­4466f
 
multiplier for level generation
-- Defaults:
DEFINE INDEX hnsw_idx ON pts FIELDS point HNSW DIMENSION 4;
-- Explicit:
DEFINE INDEX hnsw_idx ON pts FIELDS point HNSW DIMENSION 4 DIST EUCLIDEAN TYPE F64 EFC 150 M 12 M0 24 LM 0.4024­296­043­818­4466f;

Vector Search WHERE statement

Query
M-Tree index
HNSW index
<|2­|>
uses distance function defined in index
same
<|2, EUCLID­EAN­|>
brute force methood
same
<|2, COSINE­|>
brute force method
same
<|2, MANHAT­TAN­|>
brute force method
same
<|2, MINKOWSKI, 3|>
brute force method (third param is 𝑝)
same
<|2, CHEBYS­HEV­|>
brute force method
same
<|2, HAMMIN­G|>
brute force method
same
<|2, 10|>
invalid, only for HNSW
second param is effort
• p: 1: manhattan, 2: euclidean, 4: squircle, …
• effort: how far to go