[Discussion] Transactional Physical Storage for VECTOR Values in InnoDB #138
zhaiwx1987
started this conversation in
AI & Cloud
Replies: 1 comment 1 reply
|
Does this format do anything towards efficiently processing Vector values with SIMD instructions? I mean for cases where we don't have a suitable ANN index, or do not want an approximate result set? I didn't see any reference to this topic. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
[Discussion] Transactional Physical Storage for VECTOR Values in InnoDB
Executive Summary
MySQL already has a native
VECTORdata type, and the Native Vector Index work is defining how vector indexes should integrate with InnoDB. This proposal focuses on a narrower layer:It does not propose an ANN algorithm, vector-index syntax, or a specific vector-index architecture.
The proposed model stores an opaque fixed-width
VectorRefin the clustered record when a VECTOR value is externalized. The referenced value is stored in InnoDB-managed Vector Storage pages.The main design principles are:
The goal is to provide a stable base-value storage contract that can support both the current fixed-dimension dense VECTOR and future vector value families such as half-precision, sparse, or multi-vector representations, without coupling the authoritative SQL value to a particular ANN index implementation.
1. Motivation
Current MySQL vector work is primarily focused on making
VECTORsearchable and indexable. The architecture discussion inmysql/mysql-server#710is evaluating different approaches for VECTOR INDEX storage, including specialized InnoDB-managed index structures and hidden relational objects.Those are index-storage decisions.
The base VECTOR column value has a different responsibility. It must remain the durable source value even when:
The base-value layer should therefore be designed independently.
There is also a second motivation: not every future vector representation is necessarily fixed-size per row.
For example:
A storage model optimized only for one fixed payload size would make future variable-length vector values unnecessarily expensive or force them into an unrelated LOB representation.
2. Scope
This proposal covers:
It intentionally does not define:
CREATE VECTOR INDEXsyntax;3. Proposed Physical Model
The proposed model is:
The important point is that fixed-length and variable-length values are not separate storage subsystems.
They share the same basic fixed-slot page allocator.
Large values share one generalized
CHUNKED_OBJECTmechanism.3.1 VectorRef
When a VECTOR value is externalized, the clustered record stores a compact opaque
VectorRef:The current design direction is a fixed-width reference identifying a Vector page and slot. An 8-byte representation appears sufficient for the current design, although the exact bit allocation should still be validated against InnoDB page-number and slot-count limits.
VectorRefremains an InnoDB implementation detail.The Server, SQL expressions, client protocol, logical backup, and replication should see the logical VECTOR value, never physical page numbers, slot numbers, fragment identifiers, or allocation metadata.
The reference also does not need to encode:
Those are resolved from column/storage metadata and the validated target physical page.
3.2 One Fixed-Slot Framework
The core page allocator is based on fixed-size slots.
A non-empty Vector page contains exactly one slot-size class:
Mixed slot sizes inside one page are intentionally avoided.
This preserves:
Fixed-length columns
A fixed-length vector column is the simplest case:
All inline values use one slot class.
For example, a fixed-width dense vector may map to one physical slot geometry for the lifetime of that storage format.
Variable-length columns
A variable-length vector column uses the same allocator with multiple classes:
For each new value:
The allocator selects the smallest admitted class able to contain
required_bytes.Conceptually:
This is a deterministic lower-bound lookup, not a page scan.
After the class is selected:
Reads do not repeat the size-class search:
So the extra size-class logic is primarily an allocation-time concern.
3.3 Page-Class Management
Each physical Vector Storage context can maintain a small directory of size classes:
A normal allocation should not scan the entire FSEG looking for a matching page.
FULL pages leave the allocation hot path.
A completely EMPTY page may be returned to a generic empty-page pool and later reformatted for another size class:
This avoids both mixed-size page fragmentation and long-term fragmentation between size classes.
3.4 Unified Large-Value Storage: CHUNKED_OBJECT
Values too large for an admitted single-page slot use one generalized multi-page representation:
This is shared by:
There should not be separate:
The physical problem is the same: store one immutable logical byte sequence across multiple pages.
Root payload length
The root records the complete logical payload length:
For a fixed-width dense value, this length can also be cross-checked against the descriptor-derived expected size.
For a variable-size value, it records the actual row-local payload length.
However,
payload_lengthalone is not enough to establish correctness.A readable object must also have:
payload_length;Therefore:
Any short read, missing fragment, duplicate fragment, extra fragment, or reconstructed-length mismatch is corruption and must fail closed.
A linked-list-only fragment chain should not be the correctness lookup structure. Directory lookup should remain bounded and suitable for sequential/prefetchable reads.
3.5 Mixed Inline and Chunked Values in One Column
A variable-length column may naturally contain both inline fixed-slot values and chunked values at the same time.
For example:
This is normal storage state, not a migration case.
The clustered row still contains the same opaque
VectorRef.On read, the target physical page role determines whether the reference resolves to:
or:
No new SQL semantics or MVCC rules are required.
An UPDATE may also cross this boundary:
or:
Both remain ordinary copy-on-write updates.
4. Transaction Lifecycle
The proposal continues to reuse normal InnoDB transaction semantics.
4.1 INSERT
A committed row must never reference a half-built object.
4.2 UPDATE
VECTOR UPDATE uses copy-on-write:
A published VECTOR payload is immutable.
4.3 Non-VECTOR UPDATE
If the VECTOR column itself is unchanged:
No new VECTOR allocation is needed solely because another column changed.
4.4 DELETE
Vector Storage does not independently decide visibility.
4.5 Rollback
A newly allocated value that is undone belongs to normal row-undo cleanup.
Rollback and purge therefore have different targets:
No separate Vector undo subsystem is required.
5. Crash-Safe Physical Completeness
There is an unavoidable interval between allocating physical storage and safely linking it from a row.
The Vector storage layer therefore needs a small physical construction lifecycle, conceptually:
These states describe physical construction and ownership linkage only.
They are not:
SQL visibility continues to come exclusively from normal InnoDB row MVCC.
Crash recovery must guarantee:
The implementation should reuse existing transaction identity, row undo, page redo, and InnoDB recovery infrastructure rather than introducing another transaction log.
6. Exact Search and SIMD Access
A useful point raised in this discussion is whether the storage model also helps exact vector processing when an ANN index is unavailable or approximation is not desired.
The proposal does not define SIMD execution itself, but the physical format should not make SIMD unnecessarily expensive.
The main storage requirement should be:
For a single-slot value, the payload can normally be exposed as one naturally aligned contiguous span.
For a chunked value, the storage provider should support both:
for consumers that truly require one buffer, and segmented/range access such as:
for consumers that can process the logical payload incrementally.
This allows exact metric implementations or index builders to process data without always performing:
For sparse values in particular, storage and exact processing should remain proportional to the encoded non-zero payload rather than densifying to the full logical dimension.
This design does not imply that different rows encountered during a table scan are physically contiguous. A table scan may still involve:
Therefore the PoC should explicitly measure:
This makes exact-search locality an explicit evaluation criterion rather than assuming fixed-size slots automatically solve it.
7. Relationship to Vector Index Work
This proposal remains independent of the VECTOR INDEX architecture:
Index structures may store:
Those are derived representations.
The base value remains rebuildable source data.
This separation means a future change in ANN algorithm does not require changing the SQL column's durable representation.
8. Why Not Simply Use Generic Variable-Length Records?
A general variable-length heap page could pack bytes more tightly, but it also introduces substantially more allocator machinery:
For Vector values, a segregated fixed-slot model offers a useful middle ground.
Variable-length values still choose among several fixed slot classes, while each individual page remains simple:
This bounds internal fragmentation without introducing arbitrary intra-page fragmentation.
Whether this produces a better overall result than adapted InnoDB LOB storage remains something the PoC should measure rather than assume.
9. Alternatives to Validate
Existing / adapted InnoDB LOB storage
This remains the primary baseline.
If existing LOB infrastructure can provide comparable:
then reusing it may be preferable.
Hidden base-value sub-table
This maximizes reuse of relational row semantics but adds another hidden row and lookup to every externalized base VECTOR value.
It may be appropriate for index structures while being unnecessary for base-value storage.
Full VECTOR payload in the clustered record
This avoids dereference cost for small values but reduces clustered-page density as vectors grow and increases physical copying.
A prototype should include this as a locality baseline.
10. Proposed Prototype / Validation Plan
The next useful step is a focused prototype comparing at least:
The prototype should cover both:
The required lifecycle tests are:
Large-value tests should cross the transition between:
and variable-length tests should exercise multiple size classes in the same column.
Correctness should verify:
Performance should measure:
11. Remaining Open Questions
The design direction is now more specific, but several implementation details should still be validated against InnoDB source and a PoC:
VectorRefencoding best matches InnoDB page addressing?These are implementation/PoC questions; they should not change the higher-level transaction model.
Summary
The updated proposal can be summarized as:
with the following rules:
CHUNKED_OBJECTrepresentation;The goal remains deliberately narrow:
All reactions