The index_type and index_profile preview capabilities let an extension supply its own index structure, and bind it to a custom type through a profile.
An extension can register its own index structure and have the server call into
it. The server owns the SQL syntax, the metadata, and the transaction. The
extension owns the on-disk format of the index and the search through it.Two preview capabilities carry this. vsql::preview::index_type registers the
index structure itself. vsql::preview::index_profile binds that structure to a
custom type and names the functions the index computes with. Both live in
<villagesql/preview/index_builder.h>.
Supported today: the DDL that creates, alters, and drops a custom index; index
maintenance on INSERT; and one query shape, a nearest-neighbour ordering
served by the index.Not supported: DELETE on a table whose custom index declares Index::Storage::REF_LOOKUP, an UPDATE that changes an indexed column or the primary key, and every
access pattern other than nearest-neighbour search. Four of the twelve
required hooks — mark_delete, purge, save, and restore — must exist for
the builder to compile and the server never calls them.Statements naming a custom index are refused unless
vsql_allow_preview_extensions is ON, the same setting that installing a
preview extension already requires.
The Three Pieces
An index type is the structure: how entries are stored, inserted, and scanned.
It is registered once per extension per structure, under a name like hnsw.An index function is a deterministic function bound to a profile — a distance
function, for instance. A profile binds two kinds. A function bound with
with_function() is one the optimizer may plan an index scan for. A function
bound with with_helper() is called only by the index implementation.Binding a function to a profile does not create a SQL function. The optimizer
matches an ORDER BY call by name against the profile’s bindings, so a function
bound with with_function() must also be registered with .func() under the
same name, or no statement can ever name it and the index is never chosen. A
helper needs no .func(), and calling one from SQL gives ERROR 1305 (42000): FUNCTION <database>.<name> does not exist.An index profile ties a custom type to an index type and gives each bound
function a numeric id the index calls it by. One index type serves many
profiles: vsql_vector registers a single hnsw index type and four profiles
over it — hnsw_l1, hnsw_l2, hnsw_cosine, and hnsw_inner_product — one per
distance metric.
Registering an Index Type
make_index_type<Name, Context>() takes the index name and a per-index context
struct that holds whatever run-time state the extension needs. All twelve hooks
are required, in three groups, in this order. The builder does not compile if one
is missing — the failing assertion names the hook.The lifecycle hooks create the index storage, load it when the table opens, and
drop it:
bool create(Ctx *, const Index &, Space::Ref, Segment::TrxRef, char *, uint32_t);bool load(Ctx *, const Index &, Index::StorageRef, char *, uint32_t);bool drop(Ctx *, const Index &, Segment::TrxRef, char *, uint32_t);
The DML hooks maintain the index as rows change. The server calls insert.
mark_delete and purge must exist with these signatures so the builder
compiles; stub them:
The scan hooks answer queries. The server calls begin, position, fetch, and
end, and passes position only Index::CursorOp::Next. save and restore
must exist and are stubs, like the two DML hooks above:
Every hook that can fail takes a message buffer and its length as the last two
arguments, and returns true on failure after writing the message there.The cursor belongs to the extension. Allocate it in begin and assign it to
*cursor, already positioned on the first record — the server calls fetch
before it calls position. Free the cursor in end and set *cursor to
nullptr. The SDK does not wrap cursor state.The bool * argument of begin, position, and restore is an end-of-scan
flag the hook writes. On success the server calls end even when begin set
that flag; on failure begin must leave *cursor null, and end is not
called. The MtrCtx::Refbegin receives is null on the path the server drives
today.The context does not belong to the extension. The SDK allocates
Index::StorageCtx<T> and your T from the InnoDB arena before it calls
create or load, and destroys the arena — which runs ~T — after drop
returns. Reach your own state through ctx->user() and the arena through
ctx->arena(). Never delete the context, the user object, or the arena.
Declaring What the Index Can Do
.capabilities() declares which access patterns the index supports, and
.storage_props() declares how each index entry refers back to the data it
indexes. Both are required.The builder accepts five capability values, and the server acts on one:
Index::Support::KNN, a k nearest neighbour scan for
ORDER BY <distance>(<column>, <reference>) LIMIT K. POINT_LOOKUP,
RANGE_SCAN, REVERSE_SCAN, and ORDER_BY compile and register, and the optimizer builds none of those paths. An = condition on the indexed column can still plan an Index lookup on the custom index, for example under FORCE INDEX, whatever the index declares, and that query fails with ERROR 1031 (HY000): Table storage engine for '<table>' doesn't have this option.The storage declaration that serves a nearest-neighbour scan is
Index::Storage::HAS_COLUMN_REF | Index::Storage::HAS_ROW_REF on a single-column
index over a column the extension stores itself. HAS_COLUMN_REF means each
entry stores a stable column reference the server supplies rather than the full
primary key, and it is what makes get_key_data() and get_key_ref() available.
REF_LOOKUP means the index can re-locate an entry from that reference, and it
carries an obligation: every entry must have a unique reference token.Index::Storage::HAS_ROW_REF means each entry stores the primary key of the row it indexes: the server passes it to insert() in the pkeys array, fetch() must return it in pkeys, and the server resolves each hit with a primary-key lookup. An index that does not declare it is never chosen for a nearest-neighbour scan. Declare it together with HAS_COLUMN_REF.
Reading and Writing Column References
get_key_data() resolves a KeyPartRef — the kind the DML and scan hooks hand
the index — into the key column’s actual value, sized with
get_max_col_len(key_pos). get_key_ref() goes the other way: it derives the
reference for a key column value already in the column store, such as one of
the keysinsert() receives. get_key_data() reads under its own
mini-transaction and must not be called while the extension holds page latches.
Both take key_pos, the zero-based key column the value belongs to, and
return true on failure with the message in index.get_error():
std::vector<unsigned char> buf(index.get_max_col_len(key_pos));IndexScanKey::KeyPartData key_data{buf.data(), static_cast<uint32_t>(buf.size())};// The hooks receive key_ref as a pointer; get_key_data() takes it by value.if (index.get_key_data(key_pos, *key_ref, &key_data)) return true; // index.get_error()// key_data holds the value.IndexScanKey::KeyPartRef derived_ref;if (index.get_key_ref(key_pos, keys[key_pos], &derived_ref)) return true;// derived_ref holds the reference.
The server leaves both as null function pointers unless the index declared
HAS_COLUMN_REF, and the SDK calls them unguarded, so calling either without it
crashes rather than returning an error.
Index Options
WITH (M = 8, ef_construction = 64) in the DDL reaches the extension as index
options. The server lowercases every key and value first, so params[i].key
reads m even though the DDL wrote M. Declare a struct, and a parse function that sets every field, defaults included, and register it with .options<T, &T::parse>():
struct HNSWOptions { int M; int ef_construction; static bool parse(const Index::Parameter *params, uint32_t count, HNSWOptions *out, char *error_msg, uint32_t error_msg_len);};
Set the defaults, then compare against the lowercased key:
*out = HNSWOptions{16, 200};for (uint32_t i = 0; i < count; i++) { if (strcmp(params[i].key, "m") == 0) out->M = atoi(params[i].value);}
params is null when the DDL carried no WITH clause, so count is the value
to test first. A parse that returns failure aborts the DDL, and the message it
wrote goes to the server error log — the client sees only
ERROR 1030 (HY000): Got error 168 - 'Unknown (generic) error from engine' from storage engine, so
name the index and the offending key in the message.index.options<HNSWOptions>() returns a pointer to the parsed struct. It is
reachable from every hook that receives the Index — the lifecycle hooks, the
DML hooks, and begin. The remaining scan hooks receive only a cursor, so an
index type that needs its options mid-scan has to copy them into the cursor in
begin.
Index Functions
An index function must be deterministic and must return REAL. Build one and
hold it in a static const — the profile stores a reference to it, so its
address has to outlive registration:
A function may declare at most eight parameters, the value of
VEF_INDEX_PROFILE_FN_MAX_ARGS. The server checks the return type and the arity
at INSTALL EXTENSION rather than at first use.
Index Profiles
A profile names the custom type, the index type, and the functions with their
ids. for_type() takes the type name string — the same constant passed to
make_type — not the type descriptor. with_function() and with_helper() take
a built index function, not a name:
Ids must be unique within each list, and the two lists are numbered
independently — with_function(1, ...) and with_helper(1, ...) do not collide.
A repeated id inside one list is rejected at INSTALL EXTENSION..default_for_type(true) marks this profile as the one to use when a statement
names no profile. It applies per type and index type pair, and defaults to false.
vsql_vector marks hnsw_l2, which is why an index created without a profile
records hnsw_l2.INSTALL EXTENSION rejects an extension that registers two profiles with .default_for_type(true) for the same type and index type pair: Failed to install extension '<extension>': index profile '<profile>': type '<type>' with index type '<index_type>' already has a default index profile '<other_profile>'..ordering() records the scan directions the profile supports, as NONE, ASC,
DESC, or ASC | DESC. The server stores the value and nothing reads it. Only
an ascending ordering is ever planned, whatever the profile declares: a profile that declares
DESC alone still serves an ascending query, and a descending ORDER BY runs as a table scan.A hook calls a bound function through index.profile() or a bound helper
through index.helper(). Both take the key column position, the id the profile
gave the function, a pointer to the result, and the column values as
vef_storage_col_data_t arguments.index.helper_fn_name() reports the registered name of a bound helper instead of
calling it, which lets an inner loop resolve its own native implementation once
rather than dispatching per call:
A skeleton, with the hook bodies, the options struct, and the context left out:
#include <villagesql/preview/index_builder.h>#include <villagesql/vsql.h>using namespace vsql::preview_index_builder;using vsql::preview_storage::MtrCtx;using vsql::preview_storage::Segment;using vsql::preview_storage::Space;static constexpr const char kMyType[] = "my_type";static constexpr const char kMyIndex[] = "my_index";constexpr auto MY_TYPE = vsql::make_type<kMyType>()/* ... */.build();static constexpr auto MY_INDEX = make_index_type<kMyIndex, MyContext>() .lifecycle() .create<&my_create>() .load<&my_load>() .drop<&my_drop>() .dml() .insert<&my_insert>() .mark_delete<&my_mark_delete>() .purge<&my_purge>() .scan() .begin<&my_begin_scan>() .position<&my_position>() .fetch<&my_fetch>() .save<&my_save>() .restore<&my_restore>() .end<&my_end_scan>() .global() .capabilities(Index::Support::KNN) .storage_props(Index::Storage::HAS_COLUMN_REF | Index::Storage::HAS_ROW_REF) .options<MyOptions, &MyOptions::parse>() .build();static const auto MY_PROFILE = make_index_profile("my_profile") .for_type(kMyType) .using_index(kMyIndex) .with_function(1, MY_INDEX_FN) .ordering(Index::Ordering::ASC) .default_for_type(true) .build();static auto INDEX_TYPE = IndexTypeCapability().index_type(MY_INDEX);static auto INDEX_PROFILE = IndexProfileCapability().index_profile(MY_PROFILE);VEF_GENERATE_ENTRY_POINTS( vsql::make_extension() .with(INDEX_TYPE) .with(INDEX_PROFILE) .type(MY_TYPE) // The bound function needs a SQL function of the same name, or no // statement can name it and the index is never chosen. .func(vsql::make_func<&my_index_fn>("my_index_fn") .returns(vsql::REAL) .param(MY_TYPE) .param(MY_TYPE) .deterministic() .build()))
Both capability objects must be static — the SDK holds pointers into them —
and each must be passed to .with() exactly once. One capability object can
carry several structures: chain .index_type() or .index_profile() per
structure.
The SQL Syntax
A custom index is selected with USING EXTENDED, and the column may name the
profile to use:
INDEX <name> (<column> [[<extension>.]<profile>] [ASC | DESC]) USING EXTENDED([<extension>.]<index_type>) [WITH (<option> = <value>[, ...])]
The indexed column must be a custom type some installed extension registers,
and when the DDL names a profile that profile must be declared for that column’s
type. A plain column is refused with
ERROR 3219 (HY000): No default index profile found: column '<name>' is not a custom type. A partitioned table is refused with
ERROR 3219 (HY000): InnoDB: Custom index is not supported on partitioned tables.The clause works inline in CREATE TABLE, and in CREATE INDEX and ALTER TABLE ADD INDEX. Both the profile and the index type may be qualified with the
extension name, which is how you disambiguate two extensions offering the same
name. When no profile is named, the server uses the profile that declared
default_for_type(true) for that type and index type.Every statement in this section needs vsql_allow_preview_extensions set to
ON, at startup or with SET PERSIST. Without it the statement is refused:
ERROR 3219 (HY000): Extended Index feature not yet implemented
Using vsql_vector as the example, build it from the vsql-vector repository, copy
vsql_vector.veb into the veb_dir, turn the setting on, and install the extension first:
SET PERSIST vsql_allow_preview_extensions = ON;INSTALL EXTENSION vsql_vector;CREATE TABLE t2 ( id INT PRIMARY KEY, a SVECTOR(4) NOT NULL, b SVECTOR(8) NOT NULL, INDEX idx_a (a) USING EXTENDED(hnsw), INDEX idx_b (b hnsw_cosine) USING EXTENDED(hnsw) WITH (M = 8, ef_construction = 64)) ENGINE=InnoDB;CREATE INDEX idx_c ON t2 (a hnsw_l1) USING EXTENDED(hnsw);ALTER TABLE t2 ADD INDEX idx_d (b vsql_vector.hnsw_inner_product) USING EXTENDED(vsql_vector.hnsw);
Dropping one is ordinary: DROP INDEX, ALTER TABLE ... DROP INDEX, or
DROP TABLE, which removes the index metadata with the table. A custom index
and the rows it holds survive a server restart.The server’s key-length limit does not apply to a custom index. An index on a
column wider than 3072 bytes, which an ordinary index refuses with ERROR 1071,
is accepted. The index implementation enforces any key-size limit it needs.
Reading and Writing Through a Custom Index
Rows go in with INSERT, and the index is maintained as they do. Creating the
index on a table that already holds rows works too, and builds the index over
them. The build blocks writes to the table rather than running as an online DDL; reads
continue. A custom index takes the offline build path with ALGORITHM=INPLACE, ALGORITHM=COPY, or
no clause, because nothing yet replays concurrent writes into one. ALGORITHM=INSTANT and
LOCK=NONE are refused.One query shape is served by a custom index:
ORDER BY <distance>(<column>, <reference>) LIMIT K as the only ordering term,
ascending, with a constant <reference> or a prepared-statement parameter with a
bound value. A NULL or empty <reference> never gets the distance scan. The index must be single-column, its
type must declare Index::Support::KNN and Index::Storage::HAS_ROW_REF, and its bound profile must supply the
distance function. The column and the reference can be given in either order. A
query that misses any of these conditions runs as a table scan and a sort, with
no warning. EXPLAIN names the access:
CREATE TABLE docs ( id INT PRIMARY KEY, vec SVECTOR(4) NOT NULL, payload VARCHAR(32), INDEX idx_vec (vec hnsw_l2) USING EXTENDED(hnsw)) ENGINE=InnoDB;INSERT INTO docs VALUES (1,'[1.0,2.0,3.0,4.0]','one'), (2,'[5.0,6.0,7.0,8.0]','two'), (3,'[9.0,1.0,2.0,3.0]','three');EXPLAIN FORMAT=TREE SELECT id FROM docs ORDER BY L2_DISTANCE(vec,'[1.0,2.0,3.0,4.0]') LIMIT 2;
-> Limit: 2 row(s) (cost=0.55 rows=2) -> Custom index distance scan on idx_vec (cost=0.55 rows=3)
The server does not filter the index’s own hits by the reading transaction’s
view. It resolves each hit to its row, skips the rows that view cannot see, and
takes the next candidate — so begin should hand back its whole search pool
rather than exactly limit entries, or a concurrent write leaves the query
short of K rows.An UPDATE that changes an indexed column is refused:
UPDATE docs SET vec = '[0.0,0.0,0.0,0.0]' WHERE id = 1;
ERROR 3219 (HY000): UPDATE that changes an indexed column on a table with a custom index (USING EXTENDED) is not supported yet.
An UPDATE that changes the primary key draws the same error, as does a
REPLACE that hits an existing row or an INSERT ... ON DUPLICATE KEY UPDATE that assigns an indexed
column or the primary key. An UPDATE or an INSERT ... ON DUPLICATE KEY UPDATE that assigns only
unindexed columns succeeds.An ALTER TABLE that changes the primary key of a table with a custom index is
refused regardless of ALGORITHM:
ALTER TABLE docs MODIFY id BIGINT NOT NULL;
ERROR 3219 (HY000): VillageSQL: Changing the primary key of a table with a USING EXTENDED index is not supported
Adding a column, or modifying a column other than the primary key, leaves the
table’s existing custom index in place. Forcing a table rebuild with
ALGORITHM=COPY or ALGORITHM=INPLACE also leaves the index in place, and a
rebuilt index survives a restart.
What the Server Reports
SHOW CREATE TABLE renders a custom index’s bound profile, index type, and any
WITH parameters:
KEY `idx_b` (`b` `vsql_vector`.`hnsw_cosine`) USING EXTENDED(`vsql_vector`.`hnsw`) WITH (`ef_construction` = 64, `m` = 8)
The profile and the index type are always backtick-quoted extension.name
identifiers, never a string. Both the key and the value of a WITH parameter are
lowercased and sorted alphabetically by key — the same normalization described
under Index Options above — so a key written M renders as m. The profile is
always shown, even when the DDL never named one and the server resolved it to the
type’s default: the persisted metadata records only the resolved name. The
rendering round-trips, so replaying a captured SHOW CREATE TABLE string
reproduces an index that renders identically.INFORMATION_SCHEMA.STATISTICS.INDEX_TYPE and SHOW INDEX report the index-type
name passed to USING EXTENDED(...), uppercased, in place of the storage
engine’s own algorithm name. The value carries no extension qualifier, so two
extensions offering the same index-type name are indistinguishable in this
column. A plain B-tree index on the same table still reports BTREE:
SELECT INDEX_NAME, INDEX_TYPEFROM INFORMATION_SCHEMA.STATISTICSWHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='t2'ORDER BY INDEX_NAME;
After DROP INDEX idx_a ON t2, its row is gone from this query too.
Where the Metadata Lives
The server records each custom index in villagesql.custom_indexes, and its
key columns — with the profile bound to each — in
villagesql.custom_index_columns. Both survive a restart.Neither is readable from SQL, including as root:
SELECT * FROM villagesql.custom_indexes;
ERROR 3554 (HY000): Access to table 'villagesql.custom_indexes' is rejected.
Treat them as server-internal. SHOW CREATE TABLE and
INFORMATION_SCHEMA.STATISTICS are the supported way to inspect a custom index
from a client.
{"docsConfig":{"theme":"aspen","$schema":"https://mintlify.com/docs.json","name":"VillageSQL Docs","description":"Documentation for VillageSQL, a drop-in replacement for MySQL that offers extensions.","colors":{"primary":"#9500BF","light":"#CC66FF","dark":"#1F062A"},"logo":{"light":"https://mintcdn.com/villagesql/ER5Fb1fv5K0c6u26/images/logo-light.svg?fit=max\u0026auto=format\u0026n=ER5Fb1fv5K0c6u26\u0026q=85\u0026s=984aeecbb83c7ff4d729220dc5b295ba","dark":"https://mintcdn.com/villagesql/ER5Fb1fv5K0c6u26/images/logo-dark.svg?fit=max\u0026auto=format\u0026n=ER5Fb1fv5K0c6u26\u0026q=85\u0026s=7c54878160d03b398facdce3c68e8f53","href":"https://villagesql.com"},"favicon":"https://mintcdn.com/villagesql/dJP528IM9EMOJWSW/images/favicon.png?fit=max\u0026auto=format\u0026n=dJP528IM9EMOJWSW\u0026q=85\u0026s=dcd56233103a4ed589abde42130b2a1d","background":{"color":{"dark":"#1F062A"}},"navbar":{"links":[{"icon":"github","href":"https://github.com/villagesql/villagesql-server","label":"GitHub"},{"icon":"discord","href":"https://discord.gg/KSr6whd3Fr","label":"Discord"}]},"footer":{"socials":{"github":"https://github.com/villagesql/villagesql-server","discord":"https://discord.gg/KSr6whd3Fr","linkedin":"https://www.linkedin.com/company/villagesql"}},"seo":{"metatags":{"og:type":"website","og:site_name":"VillageSQL Docs"},"indexing":"all"},"fonts":{"heading":{"family":"Space Grotesk"}},"styling":{"eyebrows":"breadcrumbs","latex":true},"errors":{"404":{"redirect":false,"title":"This is not the village you are looking for (Error 404)","description":"It looks like you got lost looking for the village. Please go back to the [documentation site](https://villagesql.com/docs) to find what you need."}},"contextual":{"options":["copy","view","claude","chatgpt","perplexity","mcp","cursor","vscode"],"display":"header"},"navigation":{"languages":[{"language":"en","default":true,"href":""},{"language":"ja","href":"ja"},{"language":"ko","href":"ko"},{"language":"zh","href":"zh"},{"language":"pt-BR","href":"pt-BR"}]}},"deployment":{"deploymentMetadataValue":{"subdomain":"villagesql","hasAudioNarration":false,"actualSubdomain":"villagesql","customDomains":["villagesql.com"],"gitSource":{"type":"github","owner":"villagesql","repo":"villagesql-docs","deployBranch":"main","contentDirectory":"","isPrivate":false,"mountPath":"","label":"","_id":"6b10c3b89ffae5051c40607d"},"feedback":{"thumbs":true,"issues":true,"edits":true,"agentFeedback":true},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6b13389d9e976889bba3cb67","clientVersion":"0.0.4458","searchFilterCounts":[{"language":"en","tag":"Guides","count":144},{"language":"ja","tag":"ガイド","count":144},{"language":"ko","tag":"가이드","count":144},{"language":"pt-BR","tag":"Guias","count":144},{"language":"zh","tag":"指南","count":144},{"language":"en","tag":"MySQL Tutorial","count":46},{"language":"ja","tag":"MySQL Tutorial","count":46},{"language":"ko","tag":"MySQL Tutorial","count":46},{"language":"pt-BR","tag":"MySQL Tutorial","count":46},{"language":"zh","tag":"MySQL Tutorial","count":46},{"language":"en","tag":"Extensions","count":45},{"language":"ja","tag":"拡張機能","count":42},{"language":"ko","tag":"확장 기능","count":42},{"language":"pt-BR","tag":"Extensões","count":42},{"language":"zh","tag":"扩展","count":42},{"language":"en","tag":"Server","count":28},{"language":"en","tag":"Dev releases","count":28},{"language":"en","tag":"Extension Catalog","count":27},{"language":"en","tag":"Available Extensions","count":27},{"language":"ja","tag":"拡張機能カタログ","count":24},{"language":"ja","tag":"利用可能な拡張機能","count":24},{"language":"ko","tag":"확장 기능 카탈로그","count":24},{"language":"ko","tag":"사용 가능한 확장 기능","count":24},{"language":"pt-BR","tag":"Catálogo de Extensões","count":24},{"language":"pt-BR","tag":"Extensões Disponíveis","count":24},{"language":"zh","tag":"扩展目录","count":24},{"language":"zh","tag":"可用扩展","count":24},{"language":"en","tag":"Operate MySQL","count":21},{"language":"ja","tag":"MySQL の運用","count":21},{"language":"ko","tag":"MySQL 운영","count":21},{"language":"pt-BR","tag":"Opere o MySQL","count":21},{"language":"zh","tag":"运维 MySQL","count":21},{"language":"en","tag":"Write Queries","count":20},{"language":"ja","tag":"クエリの作成","count":20},{"language":"ko","tag":"쿼리 작성","count":20},{"language":"pt-BR","tag":"Escreva Consultas","count":20},{"language":"zh","tag":"编写查询","count":20},{"language":"ja","tag":"拡張機能の作成","count":17},{"language":"en","tag":"Install and Run Server","count":16},{"language":"ja","tag":"データの保存","count":16},{"language":"ko","tag":"데이터 저장","count":16},{"language":"pt-BR","tag":"Armazene Dados","count":16},{"language":"zh","tag":"存储数据","count":16},{"language":"ko","tag":"확장 기능 빌드","count":15},{"language":"pt-BR","tag":"Criar uma Extensão","count":15},{"language":"zh","tag":"构建扩展","count":15},{"language":"ja","tag":"C++ SDK","count":14},{"language":"ko","tag":"C++ SDK","count":14},{"language":"pt-BR","tag":"SDK C++","count":14},{"language":"zh","tag":"C++ SDK","count":14}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":true,"enableAskAiSearchBar":true,"deflection":{"enabled":true,"email":"help@villagesql.com","showHelpButton":true}},"basePath":"/docs","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"control","enabled":true,"payload":{"type":"string","value":"control"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"auth-vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"starterQuestions":[],"googleFontsInlined":true},"customCss":[{"filePath":"style.css","content":".nav-dropdown-products-selector-trigger{order:1!important}.hidden.lg\\:flex.items-center.gap-x-2{order:2!important}#navbar,#sidebar,#mobile-nav,#table-of-contents{font-family:var(--font-family-headings-custom)}body{font-family:Arial, sans-serif}button.nav-tabs-item>div.font-medium{color:rgb(var(--gray-800))}html.dark button.nav-tabs-item>div.font-medium{color:rgb(var(--gray-200))}img.nav-logo{height:2.5rem!important;width:auto!important}img[src$=\"/images/pelican.svg\"]{width:1.5rem!important;height:1.5rem!important;margin:-0.25rem}@media (min-width: 1024px){li.navbar-link>a{font-size:0;gap:0;padding:0.5rem}li.navbar-link>a svg{height:1.25rem;width:1.25rem}}[data-callout-type=\"tip\"],[data-callout-type=\"note\"],[data-callout-type=\"info\"]{border-color:#CC66FF!important;background-color:rgb(204 102 255 / 0.08)!important}[data-callout-type=\"warning\"]{border:2px solid #B500BA!important;background-color:#FFFFFF!important}[data-callout-type] [data-component-part=\"callout-content\"]{color:#1F062A!important}[data-callout-type] [data-component-part=\"callout-icon\"] svg{color:#9500BF!important}[data-callout-type=\"warning\"] [data-component-part=\"callout-icon\"] svg{color:#630080!important}html.dark [data-callout-type=\"tip\"],html.dark [data-callout-type=\"note\"],html.dark [data-callout-type=\"info\"]{border-color:#630080!important;background-color:rgb(204 102 255 / 0.08)!important}html.dark [data-callout-type=\"warning\"]{border-color:#B500BA!important;background-color:transparent!important}html.dark [data-callout-type] [data-component-part=\"callout-content\"]{color:#FFFFFF!important}html.dark [data-callout-type] [data-component-part=\"callout-icon\"] svg{color:#CC66FF!important}.agent-setup #ask-assistant-code-block-button{display:none}html.dark .code-block [class*=\"dark:bg-codeblock\"]{background-color:#1F062A!important}html.dark .code-block [class=\"print:hidden\"]{background-image:linear-gradient(to right, rgb(31 6 42 / 0) 0px, rgb(31 6 42 / 0.2) 10px,\n rgb(31 6 42 / 0.5) 25px, rgb(31 6 42 / 0.8) 35px, rgb(31 6 42) 45px)!important}.chat-assistant-floating-input{display:none!important}"}]}
{"page":{"pagePath":"en/extensions/build/custom-indexes","slug":"/en/extensions/build/custom-indexes","pageMetadata":{"audience":"extension-author","title":"Custom Indexes","description":"The index_type and index_profile preview capabilities let an extension supply its own index structure, and bind it to a custom type through a profile.","href":"/en/extensions/build/custom-indexes"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"The index_type and index_profile preview capabilities let an extension supply its own index structure, and bind it to a custom type through a profile.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={code:`code`,em:`em`,p:`p`,pre:`pre`,span:`span`,..._provideComponents(),...props.components},{CodeBlock,Heading,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`An extension can register its own index structure and have the server call into\nit. The server owns the SQL syntax, the metadata, and the transaction. The\nextension owns the on-disk format of the index and the search through it.`}),`\n`,_jsxs(_components.p,{children:[`Two preview capabilities carry this. `,_jsx(_components.code,{children:`vsql::preview::index_type`}),` registers the\nindex structure itself. `,_jsx(_components.code,{children:`vsql::preview::index_profile`}),` binds that structure to a\ncustom type and names the functions the index computes with. Both live in\n`,_jsx(_components.code,{children:`\u003cvillagesql/preview/index_builder.h>`}),`.`]}),`\n`,_jsxs(Warning,{children:[_jsxs(_components.p,{children:[`Supported today: the DDL that creates, alters, and drops a custom index; index\nmaintenance on `,_jsx(_components.code,{children:`INSERT`}),`; and one query shape, a nearest-neighbour ordering\nserved by the index.`]}),_jsxs(_components.p,{children:[`Not supported: `,_jsx(_components.code,{children:`DELETE`}),` on a table whose custom index declares `,_jsx(_components.code,{children:`Index::Storage::REF_LOOKUP`}),`, an `,_jsx(_components.code,{children:`UPDATE`}),` that changes an indexed column or the primary key, and every\naccess pattern other than nearest-neighbour search. Four of the twelve\nrequired hooks — `,_jsx(_components.code,{children:`mark_delete`}),`, `,_jsx(_components.code,{children:`purge`}),`, `,_jsx(_components.code,{children:`save`}),`, and `,_jsx(_components.code,{children:`restore`}),` — must exist for\nthe builder to compile and the server never calls them.`]}),_jsxs(_components.p,{children:[`Statements naming a custom index are refused unless\n`,_jsx(_components.code,{children:`vsql_allow_preview_extensions`}),` is `,_jsx(_components.code,{children:`ON`}),`, the same setting that installing a\npreview extension already requires.`]})]}),`\n`,_jsx(Heading,{level:`2`,id:`the-three-pieces`,children:`The Three Pieces`}),`\n`,_jsxs(_components.p,{children:[`An index type is the structure: how entries are stored, inserted, and scanned.\nIt is registered once per extension per structure, under a name like `,_jsx(_components.code,{children:`hnsw`}),`.`]}),`\n`,_jsxs(_components.p,{children:[`An index function is a deterministic function bound to a profile — a distance\nfunction, for instance. A profile binds two kinds. A function bound with\n`,_jsx(_components.code,{children:`with_function()`}),` is one the optimizer may plan an index scan for. A function\nbound with `,_jsx(_components.code,{children:`with_helper()`}),` is called only by the index implementation.`]}),`\n`,_jsxs(_components.p,{children:[`Binding a function to a profile does not create a SQL function. The optimizer\nmatches an `,_jsx(_components.code,{children:`ORDER BY`}),` call by name against the profile’s bindings, so a function\nbound with `,_jsx(_components.code,{children:`with_function()`}),` must also be registered with `,_jsx(_components.code,{children:`.func()`}),` under the\nsame name, or no statement can ever name it and the index is never chosen. A\nhelper needs no `,_jsx(_components.code,{children:`.func()`}),`, and calling one from SQL gives `,_jsx(_components.code,{children:`ERROR 1305 (42000): FUNCTION \u003cdatabase>.\u003cname> does not exist`}),`.`]}),`\n`,_jsxs(_components.p,{children:[`An index profile ties a custom type to an index type and gives each bound\nfunction a numeric id the index calls it by. One index type serves many\nprofiles: `,_jsx(_components.code,{children:`vsql_vector`}),` registers a single `,_jsx(_components.code,{children:`hnsw`}),` index type and four profiles\nover it — `,_jsx(_components.code,{children:`hnsw_l1`}),`, `,_jsx(_components.code,{children:`hnsw_l2`}),`, `,_jsx(_components.code,{children:`hnsw_cosine`}),`, and `,_jsx(_components.code,{children:`hnsw_inner_product`}),` — one per\ndistance metric.`]}),`\n`,_jsx(Heading,{level:`2`,id:`registering-an-index-type`,children:`Registering an Index Type`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`make_index_type\u003cName, Context>()`}),` takes the index name and a per-index context\nstruct that holds whatever run-time state the extension needs. All twelve hooks\nare required, in three groups, in this order. The builder does not compile if one\nis missing — the failing assertion names the hook.`]}),`\n`,_jsx(_components.p,{children:`The lifecycle hooks create the index storage, load it when the table opens, and\ndrop it:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`3`,language:`cpp`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`cpp`,children:_jsxs(_components.code,{language:`cpp`,numberOfLines:`3`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`bool`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` create`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Ctx`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` Index`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` \u0026`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Space`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Ref`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Segment`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`TrxRef`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`char`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`uint32_t`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`bool`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` load`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Ctx`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` Index`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` \u0026`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Index`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`StorageRef`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`char`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`uint32_t`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`bool`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` drop`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Ctx`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` Index`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` \u0026`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Segment`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`TrxRef`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`char`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`uint32_t`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`The DML hooks maintain the index as rows change. The server calls `,_jsx(_components.code,{children:`insert`}),`.\n`,_jsx(_components.code,{children:`mark_delete`}),` and `,_jsx(_components.code,{children:`purge`}),` must exist with these signatures so the builder\ncompiles; stub them:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`11`,language:`cpp`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`cpp`,children:_jsxs(_components.code,{language:`cpp`,numberOfLines:`11`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`bool`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` insert`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Ctx`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` Index`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` \u0026`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Segment`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`TrxRef`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` IndexScanKey`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`KeyPartData`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`keys`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`IndexScanKey`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`KeyPartData`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`pkeys`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` IndexScanKey`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`KeyPartRef`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`key_ref`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`char`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`uint32_t`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`bool`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` mark_delete`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Ctx`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` Index`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` \u0026`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Segment`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`TrxRef`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` IndexScanKey`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`KeyPartRef`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`key_ref`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` IndexScanKey`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`KeyPartData`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`keys`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` IndexScanKey`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`KeyPartData`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`pkeys`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`bool`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` delete_mark`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` char`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`uint32_t`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`bool`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` purge`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Ctx`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` Index`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` \u0026`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Segment`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`TrxRef`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` IndexScanKey`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`KeyPartRef`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`key_ref`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`IndexScanKey`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`KeyPartData`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`keys`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` IndexScanKey`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`KeyPartData`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`pkeys`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`char`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`uint32_t`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`The scan hooks answer queries. The server calls `,_jsx(_components.code,{children:`begin`}),`, `,_jsx(_components.code,{children:`position`}),`, `,_jsx(_components.code,{children:`fetch`}),`, and\n`,_jsx(_components.code,{children:`end`}),`, and passes `,_jsx(_components.code,{children:`position`}),` only `,_jsx(_components.code,{children:`Index::CursorOp::Next`}),`. `,_jsx(_components.code,{children:`save`}),` and `,_jsx(_components.code,{children:`restore`}),`\nmust exist and are stubs, like the two DML hooks above:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`9`,language:`cpp`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`cpp`,children:_jsxs(_components.code,{language:`cpp`,numberOfLines:`9`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`bool`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` begin`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Ctx`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` Index`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` \u0026`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`MtrCtx`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Ref`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` IndexScanDesc`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` \u0026`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` Index`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Cursor`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`bool`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`char`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`uint32_t`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`bool`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` position`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Index`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Cursor`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Index`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`CursorOp`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`bool`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`char`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`uint32_t`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`bool`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` fetch`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Index`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Cursor`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`IndexScanKey`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`KeyPartRef`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` IndexScanKey`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`KeyPartData`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`keys`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`IndexScanKey`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`KeyPartData`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`pkeys`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` char`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`uint32_t`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`bool`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` save`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Index`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Cursor`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`char`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`uint32_t`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`bool`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` restore`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Index`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Cursor`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`MtrCtx`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Ref`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`bool`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`char`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`uint32_t`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`void`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` end`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Index`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Cursor`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Every hook that can fail takes a message buffer and its length as the last two\narguments, and returns `,_jsx(_components.code,{children:`true`}),` on failure after writing the message there.`]}),`\n`,_jsxs(_components.p,{children:[`The cursor belongs to the extension. Allocate it in `,_jsx(_components.code,{children:`begin`}),` and assign it to\n`,_jsx(_components.code,{children:`*cursor`}),`, already positioned on the first record — the server calls `,_jsx(_components.code,{children:`fetch`}),`\nbefore it calls `,_jsx(_components.code,{children:`position`}),`. Free the cursor in `,_jsx(_components.code,{children:`end`}),` and set `,_jsx(_components.code,{children:`*cursor`}),` to\n`,_jsx(_components.code,{children:`nullptr`}),`. The SDK does not wrap cursor state.`]}),`\n`,_jsxs(_components.p,{children:[`The `,_jsx(_components.code,{children:`bool *`}),` argument of `,_jsx(_components.code,{children:`begin`}),`, `,_jsx(_components.code,{children:`position`}),`, and `,_jsx(_components.code,{children:`restore`}),` is an end-of-scan\nflag the hook writes. On success the server calls `,_jsx(_components.code,{children:`end`}),` even when `,_jsx(_components.code,{children:`begin`}),` set\nthat flag; on failure `,_jsx(_components.code,{children:`begin`}),` must leave `,_jsx(_components.code,{children:`*cursor`}),` null, and `,_jsx(_components.code,{children:`end`}),` is not\ncalled. The `,_jsx(_components.code,{children:`MtrCtx::Ref`}),` `,_jsx(_components.code,{children:`begin`}),` receives is null on the path the server drives\ntoday.`]}),`\n`,_jsxs(_components.p,{children:[`The context does not belong to the extension. The SDK allocates\n`,_jsx(_components.code,{children:`Index::StorageCtx\u003cT>`}),` and your `,_jsx(_components.code,{children:`T`}),` from the InnoDB arena before it calls\n`,_jsx(_components.code,{children:`create`}),` or `,_jsx(_components.code,{children:`load`}),`, and destroys the arena — which runs `,_jsx(_components.code,{children:`~T`}),` — after `,_jsx(_components.code,{children:`drop`}),`\nreturns. Reach your own state through `,_jsx(_components.code,{children:`ctx->user()`}),` and the arena through\n`,_jsx(_components.code,{children:`ctx->arena()`}),`. Never delete the context, the user object, or the arena.`]}),`\n`,_jsx(Heading,{level:`3`,id:`declaring-what-the-index-can-do`,children:`Declaring What the Index Can Do`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`.capabilities()`}),` declares which access patterns the index supports, and\n`,_jsx(_components.code,{children:`.storage_props()`}),` declares how each index entry refers back to the data it\nindexes. Both are required.`]}),`\n`,_jsxs(_components.p,{children:[`The builder accepts five capability values, and the server acts on one:\n`,_jsx(_components.code,{children:`Index::Support::KNN`}),`, a k nearest neighbour scan for\n`,_jsx(_components.code,{children:`ORDER BY \u003cdistance>(\u003ccolumn>, \u003creference>) LIMIT K`}),`. `,_jsx(_components.code,{children:`POINT_LOOKUP`}),`,\n`,_jsx(_components.code,{children:`RANGE_SCAN`}),`, `,_jsx(_components.code,{children:`REVERSE_SCAN`}),`, and `,_jsx(_components.code,{children:`ORDER_BY`}),` compile and register, and the optimizer builds none of those paths. An `,_jsx(_components.code,{children:`=`}),` condition on the indexed column can still plan an `,_jsx(_components.code,{children:`Index lookup`}),` on the custom index, for example under `,_jsx(_components.code,{children:`FORCE INDEX`}),`, whatever the index declares, and that query fails with `,_jsx(_components.code,{children:`ERROR 1031 (HY000): Table storage engine for '\u003ctable>' doesn't have this option`}),`.`]}),`\n`,_jsxs(_components.p,{children:[`The storage declaration that serves a nearest-neighbour scan is\n`,_jsx(_components.code,{children:`Index::Storage::HAS_COLUMN_REF | Index::Storage::HAS_ROW_REF`}),` on a single-column\nindex over a column the extension stores itself. `,_jsx(_components.code,{children:`HAS_COLUMN_REF`}),` means each\nentry stores a stable column reference the server supplies rather than the full\nprimary key, and it is what makes `,_jsx(_components.code,{children:`get_key_data()`}),` and `,_jsx(_components.code,{children:`get_key_ref()`}),` available.\n`,_jsx(_components.code,{children:`REF_LOOKUP`}),` means the index can re-locate an entry from that reference, and it\ncarries an obligation: every entry must have a unique reference token.`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`Index::Storage::HAS_ROW_REF`}),` means each entry stores the primary key of the row it indexes: the server passes it to `,_jsx(_components.code,{children:`insert()`}),` in the `,_jsx(_components.code,{children:`pkeys`}),` array, `,_jsx(_components.code,{children:`fetch()`}),` must return it in `,_jsx(_components.code,{children:`pkeys`}),`, and the server resolves each hit with a primary-key lookup. An index that does not declare it is never chosen for a nearest-neighbour scan. Declare it together with `,_jsx(_components.code,{children:`HAS_COLUMN_REF`}),`.`]}),`\n`,_jsx(Heading,{level:`3`,id:`reading-and-writing-column-references`,children:`Reading and Writing Column References`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`get_key_data()`}),` resolves a `,_jsx(_components.code,{children:`KeyPartRef`}),` — the kind the DML and scan hooks hand\nthe index — into the key column’s actual value, sized with\n`,_jsx(_components.code,{children:`get_max_col_len(key_pos)`}),`. `,_jsx(_components.code,{children:`get_key_ref()`}),` goes the other way: it derives the\nreference for a key column value already in the column store, such as one of\nthe `,_jsx(_components.code,{children:`keys`}),` `,_jsx(_components.code,{children:`insert()`}),` receives. `,_jsx(_components.code,{children:`get_key_data()`}),` reads under its own\nmini-transaction and must not be called while the extension holds page latches.\nBoth take `,_jsx(_components.code,{children:`key_pos`}),`, the zero-based key column the value belongs to, and\nreturn `,_jsx(_components.code,{children:`true`}),` on failure with the message in `,_jsx(_components.code,{children:`index.get_error()`}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`9`,language:`cpp`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`cpp`,children:_jsxs(_components.code,{language:`cpp`,numberOfLines:`9`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`std`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`vector`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`unsigned`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` char`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`> `}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`buf`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`index`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`get_max_col_len`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(key_pos));`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`IndexScanKey`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::KeyPartData key_data{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`buf`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`data`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(), `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`static_cast`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`uint32_t`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`buf`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`size`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`())};`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// The hooks receive key_ref as a pointer; get_key_data() takes it by value.`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`index`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`get_key_data`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(key_pos, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`key_ref, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u0026`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`key_data)) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`return`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` true`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // index.get_error()`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// key_data holds the value.`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`IndexScanKey`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::KeyPartRef derived_ref;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`index`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`get_key_ref`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(key_pos, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`keys`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[key_pos], `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u0026`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`derived_ref)) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`return`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` true`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// derived_ref holds the reference.`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`The server leaves both as null function pointers unless the index declared\n`,_jsx(_components.code,{children:`HAS_COLUMN_REF`}),`, and the SDK calls them unguarded, so calling either without it\ncrashes rather than returning an error.`]}),`\n`,_jsx(Heading,{level:`3`,id:`index-options`,children:`Index Options`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`WITH (M = 8, ef_construction = 64)`}),` in the DDL reaches the extension as index\noptions. The server lowercases every key and value first, so `,_jsx(_components.code,{children:`params[i].key`}),`\nreads `,_jsx(_components.code,{children:`m`}),` even though the DDL wrote `,_jsx(_components.code,{children:`M`}),`. Declare a struct, and a `,_jsx(_components.code,{children:`parse`}),` function that sets every field, defaults included, and register it with `,_jsx(_components.code,{children:`.options\u003cT, \u0026T::parse>()`}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`7`,language:`cpp`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`cpp`,children:_jsxs(_components.code,{language:`cpp`,numberOfLines:`7`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`struct`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` HNSWOptions`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` int`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` M;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` int`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ef_construction;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` static`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` bool`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` parse`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` Index`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Parameter`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`params`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`uint32_t`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` count`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` HNSWOptions`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`out`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`char`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` *`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`error_msg`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` uint32_t`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` error_msg_len`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`};`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Set the defaults, then compare against the lowercased key:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`cpp`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`cpp`,children:_jsxs(_components.code,{language:`cpp`,numberOfLines:`4`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`*`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`out `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` HNSWOptions{`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`16`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`200`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`};`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`for`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`uint32_t`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` i `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`; i `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` count; i`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`++`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`strcmp`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`params`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[i].`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`key`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"m\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`==`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`out`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`->`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`M`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` atoi`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`params`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[i].`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`value`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`params`}),` is null when the DDL carried no `,_jsx(_components.code,{children:`WITH`}),` clause, so `,_jsx(_components.code,{children:`count`}),` is the value\nto test first. A `,_jsx(_components.code,{children:`parse`}),` that returns failure aborts the DDL, and the message it\nwrote goes to the server error log — the client sees only\n`,_jsx(_components.code,{children:`ERROR 1030 (HY000): Got error 168 - 'Unknown (generic) error from engine' from storage engine`}),`, so\nname the index and the offending key in the message.`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`index.options\u003cHNSWOptions>()`}),` returns a pointer to the parsed struct. It is\nreachable from every hook that receives the `,_jsx(_components.code,{children:`Index`}),` — the lifecycle hooks, the\nDML hooks, and `,_jsx(_components.code,{children:`begin`}),`. The remaining scan hooks receive only a cursor, so an\nindex type that needs its options mid-scan has to copy them into the cursor in\n`,_jsx(_components.code,{children:`begin`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`index-functions`,children:`Index Functions`}),`\n`,_jsxs(_components.p,{children:[`An index function must be deterministic and must return `,_jsx(_components.code,{children:`REAL`}),`. Build one and\nhold it in a `,_jsx(_components.code,{children:`static const`}),` — the profile stores a reference to it, so its\naddress has to outlive registration:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`7`,language:`cpp`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`cpp`,children:_jsxs(_components.code,{language:`cpp`,numberOfLines:`7`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`static`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` auto`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MY_INDEX_FN `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` make_index_function`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u0026`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`my_index_fn`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`>(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"my_index_fn\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`returns`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`vsql`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::REAL)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`param`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(MY_TYPE)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`param`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(MY_TYPE)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`deterministic`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`build`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`A function may declare at most eight parameters, the value of\n`,_jsx(_components.code,{children:`VEF_INDEX_PROFILE_FN_MAX_ARGS`}),`. The server checks the return type and the arity\nat `,_jsx(_components.code,{children:`INSTALL EXTENSION`}),` rather than at first use.`]}),`\n`,_jsx(Heading,{level:`2`,id:`index-profiles`,children:`Index Profiles`}),`\n`,_jsxs(_components.p,{children:[`A profile names the custom type, the index type, and the functions with their\nids. `,_jsx(_components.code,{children:`for_type()`}),` takes the type `,_jsx(_components.em,{children:`name string`}),` — the same constant passed to\n`,_jsx(_components.code,{children:`make_type`}),` — not the type descriptor. `,_jsx(_components.code,{children:`with_function()`}),` and `,_jsx(_components.code,{children:`with_helper()`}),` take\na built index function, not a name:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`9`,language:`cpp`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`cpp`,children:_jsxs(_components.code,{language:`cpp`,numberOfLines:`9`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`static`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` auto`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MY_PROFILE `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` make_index_profile`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"my_profile\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`for_type`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(kMyType)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`using_index`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(kMyIndex)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`with_function`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, MY_DISTANCE_FN)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`with_helper`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, MY_HELPER_FN)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`ordering`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Index`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Ordering`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::ASC)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`default_for_type`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`true`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`build`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Ids must be unique within each list, and the two lists are numbered\nindependently — `,_jsx(_components.code,{children:`with_function(1, ...)`}),` and `,_jsx(_components.code,{children:`with_helper(1, ...)`}),` do not collide.\nA repeated id inside one list is rejected at `,_jsx(_components.code,{children:`INSTALL EXTENSION`}),`.`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`.default_for_type(true)`}),` marks this profile as the one to use when a statement\nnames no profile. It applies per type and index type pair, and defaults to false.\n`,_jsx(_components.code,{children:`vsql_vector`}),` marks `,_jsx(_components.code,{children:`hnsw_l2`}),`, which is why an index created without a profile\nrecords `,_jsx(_components.code,{children:`hnsw_l2`}),`.`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`INSTALL EXTENSION`}),` rejects an extension that registers two profiles with `,_jsx(_components.code,{children:`.default_for_type(true)`}),` for the same type and index type pair: `,_jsx(_components.code,{children:`Failed to install extension '\u003cextension>': index profile '\u003cprofile>': type '\u003ctype>' with index type '\u003cindex_type>' already has a default index profile '\u003cother_profile>'`}),`.`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`.ordering()`}),` records the scan directions the profile supports, as `,_jsx(_components.code,{children:`NONE`}),`, `,_jsx(_components.code,{children:`ASC`}),`,\n`,_jsx(_components.code,{children:`DESC`}),`, or `,_jsx(_components.code,{children:`ASC | DESC`}),`. The server stores the value and nothing reads it. Only\nan ascending ordering is ever planned, whatever the profile declares: a profile that declares\n`,_jsx(_components.code,{children:`DESC`}),` alone still serves an ascending query, and a descending `,_jsx(_components.code,{children:`ORDER BY`}),` runs as a table scan.`]}),`\n`,_jsxs(_components.p,{children:[`A hook calls a bound function through `,_jsx(_components.code,{children:`index.profile()`}),` or a bound helper\nthrough `,_jsx(_components.code,{children:`index.helper()`}),`. Both take the key column position, the id the profile\ngave the function, a pointer to the result, and the column values as\n`,_jsx(_components.code,{children:`vef_storage_col_data_t`}),` arguments.`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`index.helper_fn_name()`}),` reports the registered name of a bound helper instead of\ncalling it, which lets an inner loop resolve its own native implementation once\nrather than dispatching per call:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`cpp`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`cpp`,children:_jsxs(_components.code,{language:`cpp`,numberOfLines:`4`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`std`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::array`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`char`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`64`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`>`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` name{};`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`if`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`index`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`helper_fn_name`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(key_pos, fn_id, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`name`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`data`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(), `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`name`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`size`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`())) {`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // on failure, index.get_error()`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`putting-it-together`,children:`Putting It Together`}),`\n`,_jsx(_components.p,{children:`A skeleton, with the hook bodies, the options struct, and the context left out:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`62`,language:`cpp`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`cpp`,children:_jsxs(_components.code,{language:`cpp`,numberOfLines:`62`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`#include`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \u003cvillagesql/preview/index_builder.h>`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`#include`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \u003cvillagesql/vsql.h>`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`using`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` namespace`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` vsql`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`preview_index_builder`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`using`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` vsql`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`preview_storage`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::MtrCtx;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`using`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` vsql`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`preview_storage`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::Segment;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`using`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` vsql`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`preview_storage`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::Space;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`static`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` constexpr`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` char`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` kMyType[] `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"my_type\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`static`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` constexpr`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` char`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` kMyIndex[] `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"my_index\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`constexpr`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` auto`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MY_TYPE `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` vsql`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`make_type`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`kMyType`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`>()`}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`/* ... */`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`build`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`static`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` constexpr`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` auto`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MY_INDEX `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` make_index_type`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`kMyIndex`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`MyContext`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`>()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`lifecycle`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`create`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u0026`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`my_create`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`>()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`load`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u0026`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`my_load`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`>()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`drop`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u0026`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`my_drop`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`>()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`dml`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`insert`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u0026`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`my_insert`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`>()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`mark_delete`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u0026`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`my_mark_delete`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`>()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`purge`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u0026`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`my_purge`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`>()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`scan`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`begin`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u0026`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`my_begin_scan`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`>()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`position`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u0026`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`my_position`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`>()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`fetch`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u0026`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`my_fetch`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`>()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`save`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u0026`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`my_save`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`>()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`restore`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u0026`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`my_restore`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`>()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`end`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u0026`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`my_end_scan`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`>()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`global`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`capabilities`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Index`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Support`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::KNN)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`storage_props`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Index`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Storage`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::HAS_COLUMN_REF `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`|`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` Index`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Storage`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::HAS_ROW_REF)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`options`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`MyOptions`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u0026`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`MyOptions`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`parse`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`>()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`build`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`static`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` const`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` auto`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` MY_PROFILE `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` make_index_profile`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"my_profile\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`for_type`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(kMyType)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`using_index`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(kMyIndex)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`with_function`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, MY_INDEX_FN)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`ordering`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Index`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`Ordering`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::ASC)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`default_for_type`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`true`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`build`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`static`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` auto`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` INDEX_TYPE `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` IndexTypeCapability`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`().`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`index_type`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(MY_INDEX);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`static`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` auto`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` INDEX_PROFILE `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` IndexProfileCapability`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`().`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`index_profile`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(MY_PROFILE);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`VEF_GENERATE_ENTRY_POINTS`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:` vsql`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`make_extension`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`with`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(INDEX_TYPE)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`with`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(INDEX_PROFILE)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`type`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(MY_TYPE)`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // The bound function needs a SQL function of the same name, or no`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:` // statement can name it and the index is never chosen.`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`func`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`vsql`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`make_func`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`\u003c`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`\u0026`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`my_index_fn`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`>(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"my_index_fn\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`returns`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#4EC9B0`},children:`vsql`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`::REAL)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`param`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(MY_TYPE)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`param`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(MY_TYPE)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`deterministic`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` .`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`build`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`()))`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Both capability objects must be `,_jsx(_components.code,{children:`static`}),` — the SDK holds pointers into them —\nand each must be passed to `,_jsx(_components.code,{children:`.with()`}),` exactly once. One capability object can\ncarry several structures: chain `,_jsx(_components.code,{children:`.index_type()`}),` or `,_jsx(_components.code,{children:`.index_profile()`}),` per\nstructure.`]}),`\n`,_jsx(Heading,{level:`2`,id:`the-sql-syntax`,children:`The SQL Syntax`}),`\n`,_jsxs(_components.p,{children:[`A custom index is selected with `,_jsx(_components.code,{children:`USING EXTENDED`}),`, and the column may name the\nprofile to use:`]}),`\n`,_jsx(CodeBlock,{numberOfLines:`4`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`4`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`INDEX \u003cname> (\u003ccolumn> [[\u003cextension>.]\u003cprofile>] [ASC | DESC])`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` USING EXTENDED([\u003cextension>.]\u003cindex_type>)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` [WITH (\u003coption> = \u003cvalue>[, ...])]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[`The indexed column must be a custom type some installed extension registers,\nand when the DDL names a profile that profile must be declared for that column’s\ntype. A plain column is refused with\n`,_jsx(_components.code,{children:`ERROR 3219 (HY000): No default index profile found: column '\u003cname>' is not a custom type`}),`. A partitioned table is refused with\n`,_jsx(_components.code,{children:`ERROR 3219 (HY000): InnoDB: Custom index is not supported on partitioned tables`}),`.`]}),`\n`,_jsxs(_components.p,{children:[`The clause works inline in `,_jsx(_components.code,{children:`CREATE TABLE`}),`, and in `,_jsx(_components.code,{children:`CREATE INDEX`}),` and `,_jsx(_components.code,{children:`ALTER TABLE ADD INDEX`}),`. Both the profile and the index type may be qualified with the\nextension name, which is how you disambiguate two extensions offering the same\nname. When no profile is named, the server uses the profile that declared\n`,_jsx(_components.code,{children:`default_for_type(true)`}),` for that type and index type.`]}),`\n`,_jsxs(_components.p,{children:[`Every statement in this section needs `,_jsx(_components.code,{children:`vsql_allow_preview_extensions`}),` set to\n`,_jsx(_components.code,{children:`ON`}),`, at startup or with `,_jsx(_components.code,{children:`SET PERSIST`}),`. Without it the statement is refused:`]}),`\n`,_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`ERROR 3219 (HY000): Extended Index feature not yet implemented`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[`Using `,_jsx(_components.code,{children:`vsql_vector`}),` as the example, build it from the `,_jsx(_components.code,{children:`vsql-vector`}),` repository, copy\n`,_jsx(_components.code,{children:`vsql_vector.veb`}),` into the `,_jsx(_components.code,{children:`veb_dir`}),`, turn the setting on, and install the extension first:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`15`,language:`sql`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`sql`,children:_jsxs(_components.code,{language:`sql`,numberOfLines:`15`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`SET`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` PERSIST vsql_allow_preview_extensions `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` ON`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`INSTALL EXTENSION vsql_vector;`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`CREATE`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` TABLE`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` t2`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` id `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`INT`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` PRIMARY KEY`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` a SVECTOR(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`4`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`NOT NULL`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` b SVECTOR(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`8`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`NOT NULL`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` INDEX`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` idx_a (a) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`USING`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` EXTENDED(hnsw),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` INDEX`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` idx_b (b hnsw_cosine) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`USING`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` EXTENDED(hnsw) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`WITH`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (M `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 8`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, ef_construction `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 64`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) ENGINE`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`InnoDB;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`CREATE`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` INDEX`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` idx_c`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` ON`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` t2 (a hnsw_l1) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`USING`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` EXTENDED(hnsw);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`ALTER`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` TABLE`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` t2 `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`ADD`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` INDEX`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` idx_d (b `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`vsql_vector`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`hnsw_inner_product`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` USING`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` EXTENDED(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`vsql_vector`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`hnsw`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Dropping one is ordinary: `,_jsx(_components.code,{children:`DROP INDEX`}),`, `,_jsx(_components.code,{children:`ALTER TABLE ... DROP INDEX`}),`, or\n`,_jsx(_components.code,{children:`DROP TABLE`}),`, which removes the index metadata with the table. A custom index\nand the rows it holds survive a server restart.`]}),`\n`,_jsxs(_components.p,{children:[`The server’s key-length limit does not apply to a custom index. An index on a\ncolumn wider than 3072 bytes, which an ordinary index refuses with `,_jsx(_components.code,{children:`ERROR 1071`}),`,\nis accepted. The index implementation enforces any key-size limit it needs.`]}),`\n`,_jsx(Heading,{level:`2`,id:`reading-and-writing-through-a-custom-index`,children:`Reading and Writing Through a Custom Index`}),`\n`,_jsxs(_components.p,{children:[`Rows go in with `,_jsx(_components.code,{children:`INSERT`}),`, and the index is maintained as they do. Creating the\nindex on a table that already holds rows works too, and builds the index over\nthem. The build blocks writes to the table rather than running as an online DDL; reads\ncontinue. A custom index takes the offline build path with `,_jsx(_components.code,{children:`ALGORITHM=INPLACE`}),`, `,_jsx(_components.code,{children:`ALGORITHM=COPY`}),`, or\nno clause, because nothing yet replays concurrent writes into one. `,_jsx(_components.code,{children:`ALGORITHM=INSTANT`}),` and\n`,_jsx(_components.code,{children:`LOCK=NONE`}),` are refused.`]}),`\n`,_jsxs(_components.p,{children:[`One query shape is served by a custom index:\n`,_jsx(_components.code,{children:`ORDER BY \u003cdistance>(\u003ccolumn>, \u003creference>) LIMIT K`}),` as the only ordering term,\nascending, with a constant `,_jsx(_components.code,{children:`\u003creference>`}),` or a prepared-statement parameter with a\nbound value. A `,_jsx(_components.code,{children:`NULL`}),` or empty `,_jsx(_components.code,{children:`\u003creference>`}),` never gets the distance scan. The index must be single-column, its\ntype must declare `,_jsx(_components.code,{children:`Index::Support::KNN`}),` and `,_jsx(_components.code,{children:`Index::Storage::HAS_ROW_REF`}),`, and its bound profile must supply the\ndistance function. The column and the reference can be given in either order. A\nquery that misses any of these conditions runs as a table scan and a sort, with\nno warning. `,_jsx(_components.code,{children:`EXPLAIN`}),` names the access:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`13`,language:`sql`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`sql`,children:_jsxs(_components.code,{language:`sql`,numberOfLines:`13`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`CREATE`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` TABLE`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` docs`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` id `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`INT`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` PRIMARY KEY`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` vec SVECTOR(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`4`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`NOT NULL`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` payload `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`VARCHAR`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`32`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` INDEX`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` idx_vec (vec hnsw_l2) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`USING`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` EXTENDED(hnsw)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) ENGINE`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`InnoDB;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`INSERT INTO`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` docs `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`VALUES`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'[1.0,2.0,3.0,4.0]'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'one'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`2`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'[5.0,6.0,7.0,8.0]'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'two'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` (`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`3`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'[9.0,1.0,2.0,3.0]'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'three'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`EXPLAIN FORMAT`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`TREE`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` SELECT`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` id `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`FROM`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` docs `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`ORDER BY`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` L2_DISTANCE(vec,`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'[1.0,2.0,3.0,4.0]'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`LIMIT`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 2`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`]})})}),`\n`,_jsx(CodeBlock,{numberOfLines:`3`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`3`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`-> Limit: 2 row(s) (cost=0.55 rows=2)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:` -> Custom index distance scan on idx_vec (cost=0.55 rows=3)`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[`The server does not filter the index’s own hits by the reading transaction’s\nview. It resolves each hit to its row, skips the rows that view cannot see, and\ntakes the next candidate — so `,_jsx(_components.code,{children:`begin`}),` should hand back its whole search pool\nrather than exactly `,_jsx(_components.code,{children:`limit`}),` entries, or a concurrent write leaves the query\nshort of `,_jsx(_components.code,{children:`K`}),` rows.`]}),`\n`,_jsxs(_components.p,{children:[`An `,_jsx(_components.code,{children:`UPDATE`}),` that changes an indexed column is refused:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`sql`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`sql`,children:_jsxs(_components.code,{language:`sql`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`UPDATE`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` docs `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`SET`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` vec `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '[0.0,0.0,0.0,0.0]'`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` WHERE`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` id `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 1`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`]})})}),`\n`,_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`ERROR 3219 (HY000): UPDATE that changes an indexed column on a table with a custom index (USING EXTENDED) is not supported yet.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[`An `,_jsx(_components.code,{children:`UPDATE`}),` that changes the primary key draws the same error, as does a\n`,_jsx(_components.code,{children:`REPLACE`}),` that hits an existing row or an `,_jsx(_components.code,{children:`INSERT ... ON DUPLICATE KEY UPDATE`}),` that assigns an indexed\ncolumn or the primary key. An `,_jsx(_components.code,{children:`UPDATE`}),` or an `,_jsx(_components.code,{children:`INSERT ... ON DUPLICATE KEY UPDATE`}),` that assigns only\nunindexed columns succeeds.`]}),`\n`,_jsxs(_components.p,{children:[`An `,_jsx(_components.code,{children:`ALTER TABLE`}),` that changes the primary key of a table with a custom index is\nrefused regardless of `,_jsx(_components.code,{children:`ALGORITHM`}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`sql`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`sql`,children:_jsxs(_components.code,{language:`sql`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`ALTER`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` TABLE`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` docs `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`MODIFY`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` id `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`BIGINT`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` NOT NULL`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`]})})}),`\n`,_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`ERROR 3219 (HY000): VillageSQL: Changing the primary key of a table with a USING EXTENDED index is not supported`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[`Adding a column, or modifying a column other than the primary key, leaves the\ntable’s existing custom index in place. Forcing a table rebuild with\n`,_jsx(_components.code,{children:`ALGORITHM=COPY`}),` or `,_jsx(_components.code,{children:`ALGORITHM=INPLACE`}),` also leaves the index in place, and a\nrebuilt index survives a restart.`]}),`\n`,_jsx(Heading,{level:`2`,id:`what-the-server-reports`,children:`What the Server Reports`}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`SHOW CREATE TABLE`}),` renders a custom index’s bound profile, index type, and any\n`,_jsx(_components.code,{children:`WITH`}),` parameters:`]}),`\n`,_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:\" KEY `idx_b` (`b` `vsql_vector`.`hnsw_cosine`) USING EXTENDED(`vsql_vector`.`hnsw`) WITH (`ef_construction` = 64, `m` = 8)\"})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[`The profile and the index type are always backtick-quoted `,_jsx(_components.code,{children:`extension.name`}),`\nidentifiers, never a string. Both the key and the value of a `,_jsx(_components.code,{children:`WITH`}),` parameter are\nlowercased and sorted alphabetically by key — the same normalization described\nunder Index Options above — so a key written `,_jsx(_components.code,{children:`M`}),` renders as `,_jsx(_components.code,{children:`m`}),`. The profile is\nalways shown, even when the DDL never named one and the server resolved it to the\ntype’s default: the persisted metadata records only the resolved name. The\nrendering round-trips, so replaying a captured `,_jsx(_components.code,{children:`SHOW CREATE TABLE`}),` string\nreproduces an index that renders identically.`]}),`\n`,_jsxs(_components.p,{children:[_jsx(_components.code,{children:`INFORMATION_SCHEMA.STATISTICS.INDEX_TYPE`}),` and `,_jsx(_components.code,{children:`SHOW INDEX`}),` report the index-type\nname passed to `,_jsx(_components.code,{children:`USING EXTENDED(...)`}),`, uppercased, in place of the storage\nengine’s own algorithm name. The value carries no extension qualifier, so two\nextensions offering the same index-type name are indistinguishable in this\ncolumn. A plain B-tree index on the same table still reports `,_jsx(_components.code,{children:`BTREE`}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`4`,language:`sql`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`sql`,children:_jsxs(_components.code,{language:`sql`,numberOfLines:`4`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`SELECT`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` INDEX_NAME, INDEX_TYPE`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`FROM`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:` INFORMATION_SCHEMA`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`STATISTICS`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`WHERE`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` TABLE_SCHEMA`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`DATABASE`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`() `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`AND`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` TABLE_NAME`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`'t2'`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`ORDER BY`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` INDEX_NAME;`})]}),`\n`]})})}),`\n`,_jsx(CodeBlock,{numberOfLines:`7`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`7`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`INDEX_NAME\tINDEX_TYPE`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`idx_a\tHNSW`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`idx_b\tHNSW`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`idx_c\tHNSW`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`idx_d\tHNSW`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`PRIMARY\tBTREE`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[`After `,_jsx(_components.code,{children:`DROP INDEX idx_a ON t2`}),`, its row is gone from this query too.`]}),`\n`,_jsx(Heading,{level:`2`,id:`where-the-metadata-lives`,children:`Where the Metadata Lives`}),`\n`,_jsxs(_components.p,{children:[`The server records each custom index in `,_jsx(_components.code,{children:`villagesql.custom_indexes`}),`, and its\nkey columns — with the profile bound to each — in\n`,_jsx(_components.code,{children:`villagesql.custom_index_columns`}),`. Both survive a restart.`]}),`\n`,_jsxs(_components.p,{children:[`Neither is readable from SQL, including as `,_jsx(_components.code,{children:`root`}),`:`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`sql`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`sql`,children:_jsxs(_components.code,{language:`sql`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`SELECT`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` *`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` FROM`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:` villagesql`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#D4D4D4`},children:`custom_indexes`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`]})})}),`\n`,_jsx(CodeBlock,{numberOfLines:`2`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`2`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`ERROR 3554 (HY000): Access to table 'villagesql.custom_indexes' is rejected.`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsxs(_components.p,{children:[`Treat them as server-internal. `,_jsx(_components.code,{children:`SHOW CREATE TABLE`}),` and\n`,_jsx(_components.code,{children:`INFORMATION_SCHEMA.STATISTICS`}),` are the supported way to inspect a custom index\nfrom a client.`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"audience":"extension-author","title":"Custom Indexes","description":"The index_type and index_profile preview capabilities let an extension supply its own index structure, and bind it to a custom type through a profile.","href":"/en/extensions/build/custom-indexes"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"The Three Pieces","slug":"the-three-pieces","depth":2,"children":[]},{"title":"Registering an Index Type","slug":"registering-an-index-type","depth":2,"children":[{"title":"Declaring What the Index Can Do","slug":"declaring-what-the-index-can-do","depth":3,"children":[]},{"title":"Reading and Writing Column References","slug":"reading-and-writing-column-references","depth":3,"children":[]},{"title":"Index Options","slug":"index-options","depth":3,"children":[]}]},{"title":"Index Functions","slug":"index-functions","depth":2,"children":[]},{"title":"Index Profiles","slug":"index-profiles","depth":2,"children":[]},{"title":"Putting It Together","slug":"putting-it-together","depth":2,"children":[]},{"title":"The SQL Syntax","slug":"the-sql-syntax","depth":2,"children":[]},{"title":"Reading and Writing Through a Custom Index","slug":"reading-and-writing-through-a-custom-index","depth":2,"children":[]},{"title":"What the Server Reports","slug":"what-the-server-reports","depth":2,"children":[]},{"title":"Where the Metadata Lives","slug":"where-the-metadata-lives","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":["/docs/_mintlify/custom/villagesql/2202b5e0d18501d7/consent-loader.js"],"subdomain":"villagesql","siteName":"VillageSQL Docs","title":"Custom Indexes - VillageSQL Docs","contextualStarterQuestions":[],"navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{"en":{"href":"/en/extensions/build/custom-indexes","matchLevel":0},"ja":{"href":"/ja/extensions/build/custom-indexes","matchLevel":1},"ko":{"href":"/ko/extensions/build/custom-indexes","matchLevel":1},"zh":{"href":"/zh/extensions/build/custom-indexes","matchLevel":1},"pt-BR":{"href":"/pt-BR/extensions/build/custom-indexes","matchLevel":1}}},"lastModified":"2026-11-18T19:27:51.321Z","originalFileLocation":"en/extensions/build/custom-indexes.mdx","locale":"en"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"The index_type and index_profile preview capabilities let an extension supply its own index structure, and bind it to a custom type through a profile.\">\u003cmeta data-mint-head name=\"application-name\" content=\"VillageSQL Docs\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/villagesql/LyGu9hbDVoyQmlU_/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/docs/mintlify-assets/_mintlify/favicons/villagesql/LyGu9hbDVoyQmlU_/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/villagesql/LyGu9hbDVoyQmlU_/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/villagesql/LyGu9hbDVoyQmlU_/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/villagesql/LyGu9hbDVoyQmlU_/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/villagesql/LyGu9hbDVoyQmlU_/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/villagesql/LyGu9hbDVoyQmlU_/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/villagesql/LyGu9hbDVoyQmlU_/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/villagesql/LyGu9hbDVoyQmlU_/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Custom Indexes - VillageSQL Docs\">\u003cmeta data-mint-head property=\"og:description\" content=\"The index_type and index_profile preview capabilities let an extension supply its own index structure, and bind it to a custom type through a profile.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"VillageSQL Docs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://villagesql.com/docs/en/extensions/build/custom-indexes\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://villagesql.mintlify.site/docs/_mintlify/api/og/v2?division=Preview+Capabilities\u0026amp;title=Custom+Indexes\u0026amp;description=The+index_type+and+index_profile+preview+capabilities+let+an+extension+supply+its+own+index+structure%2C+and+bind+it+to+a+custom+type+through+a+profile.\u0026amp;theme=665425dfd3eb4b80afb93c77\u0026amp;signature=6899c385a51003bde3dbd15ff02ed97c6536903d38422ba6cfff9605d2ce6fbb\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Custom Indexes - VillageSQL Docs\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"The index_type and index_profile preview capabilities let an extension supply its own index structure, and bind it to a custom type through a profile.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://villagesql.mintlify.site/docs/_mintlify/api/og/v2?division=Preview+Capabilities\u0026amp;title=Custom+Indexes\u0026amp;description=The+index_type+and+index_profile+preview+capabilities+let+an+extension+supply+its+own+index+structure%2C+and+bind+it+to+a+custom+type+through+a+profile.\u0026amp;theme=665425dfd3eb4b80afb93c77\u0026amp;signature=6899c385a51003bde3dbd15ff02ed97c6536903d38422ba6cfff9605d2ce6fbb\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/docs/mintlify-assets/_mintlify/favicons/villagesql/LyGu9hbDVoyQmlU_/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"VillageSQL Docs\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#9500BF\">\u003clink data-mint-head rel=\"canonical\" href=\"https://villagesql.com/docs/en/extensions/build/custom-indexes\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/docs/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/docs/en/extensions/build/custom-indexes.md\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"en\" href=\"https://villagesql.com/docs/en/extensions/build/custom-indexes\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"ja\" href=\"https://villagesql.com/docs/ja/extensions/build/custom-indexes\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"ko\" href=\"https://villagesql.com/docs/ko/extensions/build/custom-indexes\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"zh\" href=\"https://villagesql.com/docs/zh/extensions/build/custom-indexes\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"pt-BR\" href=\"https://villagesql.com/docs/pt-BR/extensions/build/custom-indexes\">\u003clink data-mint-head rel=\"alternate\" hreflang=\"x-default\" href=\"https://villagesql.com/docs/en/extensions/build/custom-indexes\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://villagesql.com/#organization\",\"name\":\"VillageSQL Docs\",\"url\":\"https://villagesql.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/villagesql/ER5Fb1fv5K0c6u26/images/logo-light.svg?fit=max\u0026auto=format\u0026n=ER5Fb1fv5K0c6u26\u0026q=85\u0026s=984aeecbb83c7ff4d729220dc5b295ba\"}},{\"@type\":\"WebSite\",\"@id\":\"https://villagesql.com/docs#website\",\"name\":\"VillageSQL Docs\",\"url\":\"https://villagesql.com/docs\",\"publisher\":{\"@id\":\"https://villagesql.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://villagesql.com/docs/en/extensions/build/custom-indexes#webpage\",\"url\":\"https://villagesql.com/docs/en/extensions/build/custom-indexes\",\"name\":\"Custom Indexes\",\"description\":\"The index_type and index_profile preview capabilities let an extension supply its own index structure, and bind it to a custom type through a profile.\",\"dateModified\":\"2026-11-18T19:27:51.321Z\",\"isPartOf\":{\"@id\":\"https://villagesql.com/docs#website\"},\"breadcrumb\":{\"@id\":\"https://villagesql.com/docs/en/extensions/build/custom-indexes#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://villagesql.com/docs/en/extensions/build/custom-indexes#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Build an Extension\",\"item\":\"https://villagesql.com/docs/en/extensions/build/create\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Preview Capabilities\",\"item\":\"https://villagesql.com/docs/en/extensions/build/preview-capabilities\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Custom Indexes\",\"item\":\"https://villagesql.com/docs/en/extensions/build/custom-indexes\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://villagesql.com/docs/en/extensions/build/custom-indexes#article\",\"headline\":\"Custom Indexes\",\"name\":\"Custom Indexes\",\"description\":\"The index_type and index_profile preview capabilities let an extension supply its own index structure, and bind it to a custom type through a profile.\",\"url\":\"https://villagesql.com/docs/en/extensions/build/custom-indexes\",\"mainEntityOfPage\":{\"@id\":\"https://villagesql.com/docs/en/extensions/build/custom-indexes#webpage\"},\"dateModified\":\"2026-11-18T19:27:51.321Z\",\"publisher\":{\"@id\":\"https://villagesql.com/#organization\"},\"isPartOf\":{\"@id\":\"https://villagesql.com/docs#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"VillageSQL Docs\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"VillageSQL Docs\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/docs/en/extensions/build/custom-indexes.md","siteName":"VillageSQL Docs","nav":{"global":null,"languages":[{"language":"en","default":true,"tabs":[{"tab":"Overview","pages":[{"title":"Overview","href":""}]},{"tab":"Extensions","groups":[{"group":"Install and Run Extensions","pages":[{"title":"Installing Extensions","href":"/en/extensions/install"},{"title":"Uninstalling Extensions","href":"/en/extensions/uninstall"},{"title":"Managing Extensions","href":"/en/extensions/managing"}]},{"group":"Extension Catalog","pages":[{"group":"Available Extensions","root":{"title":"Available Extensions","href":"/en/extensions/catalog"},"expanded":false,"pages":[{"title":"vsql_ai extension for MySQL","sidebarTitle":"vsql_ai","href":"/en/extensions/vsql-ai"},{"title":"vsql_boolean extension for MySQL","sidebarTitle":"vsql_boolean","href":"/en/extensions/vsql-boolean"},{"title":"vsql_branch extension for MySQL","sidebarTitle":"vsql_branch","href":"/en/extensions/vsql-branch"},{"title":"vsql_crypto extension for MySQL","sidebarTitle":"vsql_crypto","href":"/en/extensions/vsql-crypto"},{"title":"vsql_cube extension for MySQL","sidebarTitle":"vsql_cube","href":"/en/extensions/vsql-cube"},{"title":"vsql_currency extension for MySQL","sidebarTitle":"vsql_currency","href":"/en/extensions/vsql-currency"},{"title":"vsql_duckdb extension for MySQL","sidebarTitle":"vsql_duckdb","href":"/en/extensions/vsql-duckdb"},{"title":"vsql_fuzzystrmatch extension for MySQL","sidebarTitle":"vsql_fuzzystrmatch","href":"/en/extensions/vsql-fuzzystrmatch"},{"title":"vsql_http extension for MySQL","sidebarTitle":"vsql_http","href":"/en/extensions/vsql-http"},{"title":"vsql_mcp extension for MySQL","sidebarTitle":"vsql_mcp","href":"/en/extensions/vsql-mcp"},{"title":"vsql_network_address extension for MySQL","sidebarTitle":"vsql_network_address","href":"/en/extensions/vsql-network-address"},{"title":"vsql_oauth2 extension for MySQL","sidebarTitle":"vsql_oauth2","href":"/en/extensions/vsql-oauth2"},{"title":"vsql_rest extension for MySQL","sidebarTitle":"vsql_rest","href":"/en/extensions/vsql-rest"},{"title":"vsql_stat_ch extension for MySQL","sidebarTitle":"vsql_stat_ch","href":"/en/extensions/vsql-stat-ch"},{"title":"vsql_textsearch extension for MySQL","sidebarTitle":"vsql_textsearch","href":"/en/extensions/vsql-textsearch"},{"title":"vsql_trgm extension for MySQL","sidebarTitle":"vsql_trgm","href":"/en/extensions/vsql-trgm"},{"title":"vsql_uuid extension for MySQL","sidebarTitle":"vsql_uuid","href":"/en/extensions/vsql-uuid"},{"title":"prometheus_exporter extension for MySQL","sidebarTitle":"prometheus_exporter","href":"/en/extensions/prometheus-exporter"},{"title":"vsql_address_standardizer extension for MySQL","sidebarTitle":"vsql_address_standardizer","href":"/en/extensions/vsql-address-standardizer"},{"title":"vsql_hll extension for MySQL","sidebarTitle":"vsql_hll","href":"/en/extensions/vsql-hll"},{"title":"vsql_luhn extension for MySQL","sidebarTitle":"vsql_luhn","href":"/en/extensions/vsql-luhn"},{"title":"vsql_nanoid extension for MySQL","sidebarTitle":"vsql_nanoid","href":"/en/extensions/vsql-nanoid"},{"title":"vsql_pgjwt extension for MySQL","sidebarTitle":"vsql_pgjwt","href":"/en/extensions/vsql-pgjwt"},{"title":"vsql_slugify extension for MySQL","sidebarTitle":"vsql_slugify","href":"/en/extensions/vsql-slugify"},{"title":"vsql_statistics extension for MySQL","sidebarTitle":"vsql_statistics","href":"/en/extensions/vsql-statistics"},{"title":"vsql_complex extension for MySQL","sidebarTitle":"vsql_complex","href":"/en/extensions/vsql-complex"}]}]},{"group":"Build an Extension","pages":[{"title":"Creating Extensions in C++","href":"/en/extensions/build/create"},{"title":"Creating Extensions in Rust","href":"/en/extensions/build/rust-sdk"},{"title":"MySQL Extensions, Plugins, and Components","sidebarTitle":"Extensions or Plugins and Components","href":"/en/extensions/build/extensions-or-plugins"},{"title":"Extension Architecture","href":"/en/extensions/build/architecture"},{"title":"How Extensions and the ABI Behave","href":"/en/extensions/build/extension-abi-behavior"},{"title":"VEF Coverage Compared to PostgreSQL","href":"/en/extensions/build/postgresql-hooks"},{"group":"Preview Capabilities","root":{"title":"Preview Capabilities","href":"/en/extensions/build/preview-capabilities"},"expanded":false,"pages":[{"title":"Authentication Methods","href":"/en/extensions/build/preview-auth"},{"title":"Keyring Access and MySQL Services","href":"/en/extensions/build/preview-keyring-services"},{"title":"Status, System, and Session Variables","href":"/en/extensions/build/preview-server-variables"},{"title":"Thread Worker and SQL Query","href":"/en/extensions/build/preview-background-sql"},{"title":"Column Storage","description":"The vsql::preview::column_store and vsql::preview::storage capabilities let an extension register a custom binary on-disk layout with InnoDB for one of its custom types.","href":"/en/extensions/build/preview-column-storage"},{"title":"Custom Indexes","href":"/en/extensions/build/custom-indexes"},{"title":"Statement Events","description":"The vsql::preview::statement_event capability runs an extension handler after each query finishes, with the query text, timing, row counts, and connection identity.","href":"/en/extensions/build/preview-statement-events"}]},{"title":"Older Protocols","href":"/en/extensions/build/older-protocols"}]}]},{"tab":"Server","menu":[{"item":"MySQL 8.4","icon":"database","pages":[{"title":"MySQL 8.4","href":"/en/8.4/stable/introduction"}]},{"item":"Percona Server 8.4","icon":"database","pages":[{"title":"Percona Server 8.4","href":"/en/8.4/stable/percona"}]},{"item":"MySQL 9.7","icon":"database","pages":[{"title":"MySQL 9.7","href":"/en/9.7/stable/introduction"}]},{"item":"Dev releases","icon":"flask","pages":[{"title":"Dev releases","href":"/en/dev-releases"}]},{"item":"Past releases","icon":"clock-rotate-left","pages":[{"title":"Past releases","href":"/en/past-releases"}]}],"pages":[{"title":"Server","href":"/en/8.4/stable/introduction"}]},{"tab":"Reference","menu":[{"item":"C++ SDK","icon":"code","pages":[{"title":"C++ SDK","href":"/en/sdk/cpp/extension-api-reference"}]},{"item":"Rust SDK","icon":"rust","pages":[{"title":"Rust SDK","href":"/en/sdk/rust/api-reference"}]}],"pages":[{"title":"Reference","href":"/en/sdk/cpp/extension-api-reference"}]},{"tab":"Guides","pages":[{"title":"Guides","href":"/en/tutorial"}]},{"tab":"Resources","menu":[{"item":"villagesql.com","icon":"https://mintlify.s3.us-west-1.amazonaws.com/villagesql/images/pelican.svg","href":"https://villagesql.com"},{"item":"GitHub","icon":"github","href":"https://github.com/villagesql/villagesql-server"},{"item":"Issues","icon":"bug","href":"https://github.com/villagesql/villagesql-server/issues"},{"item":"Discord","icon":"discord","href":"https://discord.gg/KSr6whd3Fr"},{"item":"Blog","icon":"newspaper","href":"https://villagesql.com/blog"},{"item":"Contribute to the Server","icon":"code-pull-request","href":"https://github.com/villagesql/villagesql-server/blob/main/CONTRIBUTING.md"},{"item":"Contribute to the Docs","icon":"pen-nib","href":"https://github.com/villagesql/villagesql-docs/blob/main/CONTRIBUTING.md"}]}]},{"language":"ja","pages":[{"title":"ja","href":"/ja/extensions/build/custom-indexes"}]},{"language":"ko","pages":[{"title":"ko","href":"/ko/extensions/build/custom-indexes"}]},{"language":"zh","pages":[{"title":"zh","href":"/zh/extensions/build/custom-indexes"}]},{"language":"pt-BR","pages":[{"title":"pt-BR","href":"/pt-BR/extensions/build/custom-indexes"}]}]},"basePath":"","title":"Custom Indexes - VillageSQL Docs","deploymentId":"dpl_BsHU5ynwUyfZMwoLvGC66duJuw65","buildId":"dpl_BsHU5ynwUyfZMwoLvGC66duJuw65","dynamics":[],"chunks":[]}