Skip to content

Docs: add the Quantized vector codec to the CREATE TABLE codecs page - #111128

Merged
rschu1ze merged 5 commits into
ClickHouse:masterfrom
groeneai:groeneai/docs-quantized-codec
Jul 21, 2026
Merged

rschu1ze merged 5 commits into
ClickHouse:masterfrom
groeneai:groeneai/docs-quantized-codec

Conversation

@groeneai

@groeneai groeneai commented Jul 20, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Documentation (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Description

Adds the Quantized(...) column codec (vector-search codec, feature added in #108565) to the codecs listing on the CREATE TABLE docs page, as requested by @rschu1ze on #111084.

The entry goes under Specialized Codecs (it preprocesses vector data; it is not an encryption codec), marked experimental, and links to the full reference at Vector search with quantized codecs rather than duplicating the method/settings details that already live there.

Related: #108565 (codec feature), #111084 (negative-case tests).

Version info

  • Merged into: 26.7.1.1266 (included in 26.7 and later)

@PedroTadim PedroTadim added the can be tested Allows running workflows for external contributors label Jul 20, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [84ec719]

Summary: ✅


AI Review

Summary

This PR adds the Quantized(...) codec to the CREATE TABLE codecs page and incorporates most of the earlier review feedback. The changelog metadata is fine, but the new Quantized description still overpromises when the approximate rewrite actually engages, so I would keep the PR open until that wording is narrowed.

Findings

⚠️ Majors

  • [docs/en/sql-reference/statements/create/table.md:493] The new sentence says that MergeTree vector search queries with vector_search_use_quantized_codes will scan the quantized codes and rescore. The implementation is narrower than that: useVectorSearchWithQuantizedCodes.cpp bails out once ReadFromMergeTree::getVectorSearchParameters is set, so indexed queries keep the vector-index plan, and it also rejects anything except ascending ORDER BY L2Distance / cosineDistance. As written, the docs promise the approximate path for queries that still run exact. Suggested fix: scope the sentence to brute-force MergeTree queries without a vector similarity index, and to the supported distance-function shapes.
Final Verdict

⚠️ One accuracy issue remains in the new Quantized section. I would not merge the docs as-is; narrow the optimizer description and the rest of the entry looks good.

@clickhouse-gh clickhouse-gh Bot added the pr-documentation Documentation PRs for the specific code PR label Jul 20, 2026
@Blargian

Copy link
Copy Markdown
Member

@groeneai when opening PRs which make changes only to documentation, please use a "Docs: " prefix in the PR title. Address the review feedback on this PR as well please.

@Blargian Blargian self-assigned this Jul 20, 2026
Scope the top-k shortlist/rescore acceleration to MergeTree-family
tables (the useVectorSearchWithQuantizedCodes planner rewrite only
matches ReadFromMergeTree plans; on other engines the setting is a
no-op exact scan), and state that a NONE-category codec cannot be
chained with any other codec (including encryption), not only with a
compression codec.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai
groeneai force-pushed the groeneai/docs-quantized-codec branch from 4a4c8e7 to f0504bd Compare July 20, 2026 19:11
@groeneai groeneai changed the title Add the Quantized vector codec to the CREATE TABLE codecs docs Docs: add the Quantized vector codec to the CREATE TABLE codecs page Jul 20, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

Done - added the "Docs:" title prefix and addressed both review comments in f0504bd (scoped the top-k acceleration to MergeTree-family tables; stated the codec cannot be chained with any other codec, including encryption).


<ExperimentalBadge/>

`Quantized(method, dimensions[, ...])` — A codec for vector-search columns of type `Array(Float32)`, `Array(Float64)` or `Array(BFloat16)`. It stores the full-precision vectors unchanged and, alongside them, a compact *quantized code* per vector. On `MergeTree`-family tables, enabling `vector_search_use_quantized_codes` lets a top-`k` vector-search query scan the small codes to build a shortlist and rescore only that shortlist against the full-precision vectors. This two-stage path is approximate: it reads fewer bytes than a full-precision scan but may reduce recall. The `vector_search_index_fetch_multiplier` setting controls the shortlist size and therefore the recall/performance trade-off. `dimensions` is the vector length; supported `method` values are `rabitq`, `turboquant`, `int8`, `prefix` and `product`, each a different size / accuracy / distance-function trade-off.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence still promises the quantized-code rewrite whenever a MergeTree table has CODEC(Quantized(...)), but the implementation is narrower. src/Processors/QueryPlan/Optimizations/useVectorSearchWithQuantizedCodes.cpp returns early once ReadFromMergeTree::getVectorSearchParameters is set, and src/Processors/QueryPlan/Optimizations/optimizeTree.cpp describes this as the brute-force path for tables without a vector similarity index. A query on a MergeTree table that also has a vector index therefore keeps the index plan instead of scanning vec.quantized. Please scope the wording to brute-force / no-index queries so readers do not infer that vector_search_use_quantized_codes accelerates every top-k search on a quantized column.


<ExperimentalBadge/>

`Quantized(method, dimensions[, ...])` — A codec for vector-search columns of type `Array(Float32)`, `Array(Float64)` or `Array(BFloat16)`. It stores the full-precision vectors unchanged and, alongside them, a compact *quantized code* per vector. On `MergeTree`-family tables, enabling `vector_search_use_quantized_codes` lets a top-`k` vector-search query scan the small codes to build a shortlist and rescore only that shortlist against the full-precision vectors. This two-stage path is approximate: it reads fewer bytes than a full-precision scan but may reduce recall. The `vector_search_index_fetch_multiplier` setting controls the shortlist size and therefore the recall/performance trade-off. `dimensions` is the vector length; supported `method` values are `rabitq`, `turboquant`, `int8`, `prefix` and `product`, each a different size / accuracy / distance-function trade-off.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@groeneai Replace "small codes" by "quantized codes"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@groeneai Replace "This two-stage path is approximate: it reads fewer bytes than a full-precision scan but may reduce recall" by "This two-stage approximate neighbor search reads fewer bytes than a normal full-precision scan but may reduce recall."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@groeneai Remove sentence "The vector_search_index_fetch_multiplier setting controls the shortlist size and therefore the recall/performance trade-off."


`Quantized(method, dimensions[, ...])` — A codec for vector-search columns of type `Array(Float32)`, `Array(Float64)` or `Array(BFloat16)`. It stores the full-precision vectors unchanged and, alongside them, a compact *quantized code* per vector. On `MergeTree`-family tables, enabling `vector_search_use_quantized_codes` lets a top-`k` vector-search query scan the small codes to build a shortlist and rescore only that shortlist against the full-precision vectors. This two-stage path is approximate: it reads fewer bytes than a full-precision scan but may reduce recall. The `vector_search_index_fetch_multiplier` setting controls the shortlist size and therefore the recall/performance trade-off. `dimensions` is the vector length; supported `method` values are `rabitq`, `turboquant`, `int8`, `prefix` and `product`, each a different size / accuracy / distance-function trade-off.

The codec can only be set in `CREATE TABLE`; it cannot be added, removed, or changed through `ALTER TABLE`, including with `ADD COLUMN ... CODEC(Quantized(...))`. It is a `NONE`-category codec, so it cannot be chained with any other codec (not even an encryption codec such as `AES_128_GCM_SIV`). The two-stage shortlist-and-rescore path applies only to `MergeTree`-family tables; when `vector_search_use_quantized_codes` is off (the default), or on non-`MergeTree` engines where the setting has no effect, the same query runs as an exact scan, so the codec never changes results. For the methods, settings, and query examples, see [Vector search with quantized codecs](/engines/table-engines/mergetree-family/annindexes#vector-search-with-quantized-codecs).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@groeneai Remove "It is a NONE-category codec" and instead write directly "It cannot be chained with ..."

ENGINE = MergeTree ORDER BY id;
```

:::note

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@groeneai Remove the entire note.

Address @rschu1ze's inline review on the create-table codecs page:
link vector_search_use_quantized_codes to the settings reference, use
"quantized codes", tighten the two-stage approximate-search wording,
drop the vector_search_index_fetch_multiplier sentence, state the
chaining restriction directly, and remove the experimental note.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

Applied all six review suggestions in 5276af9:

  1. Linked vector_search_use_quantized_codes to /operations/settings/settings#vector_search_use_quantized_codes.
  2. "small codes" -> "quantized codes".
  3. Two-stage sentence replaced with "This two-stage approximate neighbor search reads fewer bytes than a normal full-precision scan but may reduce recall."
  4. Dropped the vector_search_index_fetch_multiplier sentence.
  5. Removed "It is a NONE-category codec, so"; the paragraph now states the chaining restriction directly.
  6. Removed the experimental :::note block.

@rschu1ze

Copy link
Copy Markdown
Member

@groeneai Do not push further commits. Humans will take over.

CREATE TABLE vectors
(
id UInt32,
vec Array(Float32) CODEC(Quantized('rabitq', 1536))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to BFloat16 - using Float32 for embeddings is an anti-pattern.
Change it across the whole documentation.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do. I will switch the Array(Float32) embedding examples to Array(BFloat16) across the vector-search docs in a separate PR and link it here: annindexes.md and qbit.md now, and this codecs page once #111128 merges. I will leave the lines that intentionally compare Float32 vs BFloat16 storage sizes unchanged.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened #111156 for the docs sweep: the vector-search guide embedding examples now use Array(BFloat16) (with regenerated outputs). The sample-dataset guides and the codecs-page example on line 507 here are deferred and listed in that PR (line 507 will be flipped once this PR merges, to avoid pushing to this branch).

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A small change needed.

@rschu1ze
rschu1ze dismissed alexey-milovidov’s stale review July 21, 2026 09:11

Requested changes are implemented in #111156

@rschu1ze
rschu1ze added this pull request to the merge queue Jul 21, 2026
Merged via the queue into ClickHouse:master with commit 72efe7a Jul 21, 2026
179 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 21, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…tized-codec

Docs: add the Quantized vector codec to the CREATE TABLE codecs page
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-documentation Documentation PRs for the specific code PR pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants