Skip to content

Show vector index state and ClickHouse plans - #419

Draft
iskakaushik wants to merge 1 commit into
vector-index-ddlfrom
vector-index-state
Draft

iskakaushik wants to merge 1 commit into
vector-index-ddlfrom
vector-index-state

Conversation

@iskakaushik

@iskakaushik iskakaushik commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

What

Two ways to see what ClickHouse does with vector indexes:

  • clickhouse_vector_indexes(regclass) lists a foreign table's vector similarity indexes, each with its column, definition, compressed size, and unfinished build mutations.
  • pg_clickhouse.explain_remote (default off) adds ClickHouse's own EXPLAIN indexes = 1 plan to EXPLAIN, under "Remote Plan".

Part of the vector search stack; it sits on #418.

Why

The Vector Index line from #414 names an index ClickHouse can use. With a WHERE condition, ClickHouse may instead filter rows first and compare them exactly, for example when the condition matches the primary key. The benchmark in #424 showed exactly that for its filtered searches. explain_remote shows the plan ClickHouse actually chooses.

Notes for review

  • clickhouse_vector_indexes() is a C SRF in src/vector_meta.c that reads system.data_skipping_indices and system.mutations. It counts a mutation as pending only if it builds that exact index, not one whose name starts with the same text. It rejects a table that isn't a pg_clickhouse foreign table.
  • explain_remote runs on the scan's connection and supports every EXPLAIN format. Queries with parameters are reported as unavailable, since their remote SQL has no values.
  • ExplainIndentText() isn't exported before Postgres 18, so the plan text is indented directly.
  • The Vector Index Use docs now point to explain_remote for the plan ClickHouse chooses.

@iskakaushik
iskakaushik added this pull request to stack #425 October 15, 2026 23:33
@iskakaushik
iskakaushik force-pushed the vector-index-state branch 2 times, most recently from 2e68474 to 070f500 Compare October 16, 2026 17:01
@theory theory added enhancement New feature or request pushdown Improvements to query pushdown data types Improve data type support labels Oct 19, 2026
Add `clickhouse_vector_indexes()`, which lists the vector similarity
indexes ClickHouse reports for a foreign table, with each index's
definition, compressed size, and unfinished build mutations. Users can now
see whether an index exists and whether ClickHouse has finished building
it. It counts only mutations of the index itself, not those of indexes
whose names start with its name, and rejects a table that is not a
pg_clickhouse foreign table.

Add `pg_clickhouse.explain_remote`. When on, `EXPLAIN` runs `EXPLAIN
indexes = 1` on ClickHouse for each foreign scan and shows the result under
"Remote Plan". That plan lists the indexes ClickHouse actually uses,
including vector similarity indexes. This matters because the `Vector
Index` line names an index ClickHouse can use, not one it must: with a
`WHERE` condition, it may filter rows first and compare them exactly.
Queries with parameters are not explained, since their remote SQL has no
values.

`ExplainIndentText()` is not exported before Postgres 18, so indent the
remote plan directly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data types Improve data type support enhancement New feature or request pushdown Improvements to query pushdown

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants