Cheatography
https://cheatography.com
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_IDS_ORDER |
100 |
DOC_IDS_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_IDS_ORDER 100 DOC_IDS_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 construction |
M |
12 |
|
max connections per element |
M0 |
24 |
|
max connections in the lowest |
LM |
0.40242960438184466f |
|
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.40242960438184466f;
|
Vector Search WHERE statement
Query |
M-Tree index |
HNSW index |
<|2|> |
uses distance function defined in index |
same |
<|2, EUCLIDEAN|> |
brute force methood |
same |
<|2, COSINE|> |
brute force method |
same |
<|2, MANHATTAN|> |
brute force method |
same |
<|2, MINKOWSKI, 3|> |
brute force method (third param is 𝑝) |
same |
<|2, CHEBYSHEV|> |
brute force method |
same |
<|2, HAMMING|> |
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
|