Skip to content

feat(query): support indexes on materialized views - #20361

Open
TCeason wants to merge 1 commit into
databendlabs:mainfrom
TCeason:mv_index
Open

feat(query): support indexes on materialized views#20361
TCeason wants to merge 1 commit into
databendlabs:mainfrom
TCeason:mv_index

Conversation

@TCeason

@TCeason TCeason commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

  • Support CREATE and DROP for inverted, NGRAM, vector, and spatial indexes on non-aggregating materialized views.
  • Only synchronous index creation is supported.
  • Build synchronous index files for blocks written by REFRESH MATERIALIZED VIEW.
  • Existing materialized view blocks are not backfilled.
  • Explicit REFRESH ... INDEX ... ON materialized views and index read paths remain out of scope.

Rejected Cases

Asynchronous indexes

  CREATE ASYNC INVERTED INDEX idx ON mv(content); -- rejected

Aggregating materialized views

  CREATE MATERIALIZED VIEW mv_agg (content, row_count) AS
    SELECT content, COUNT(*)
    FROM source
    GROUP BY content;

  CREATE INVERTED INDEX idx ON mv_agg(content); -- rejected

Internal materialized view columns

  CREATE INVERTED INDEX idx ON mv(_mv_source_row_id); -- rejected

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

AI assistance

  • AI usage: AI generated the base code, and I reviewed the diff.
  • Responsible human: @TCeason
  • The responsible human has read every line of this diff and can explain each change

This change is Reviewable

@github-actions github-actions Bot added the pr-feature this PR introduces a new feature to the codebase label Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-feature this PR introduces a new feature to the codebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant