Skip to content

fix(index): skip scalar index rewrite when no unindexed fragments#6905

Open
zhangyue19921010 wants to merge 2 commits into
lance-format:mainfrom
zhangyue19921010:fix-scalar-optimize-noop-rewrite-final
Open

fix(index): skip scalar index rewrite when no unindexed fragments#6905
zhangyue19921010 wants to merge 2 commits into
lance-format:mainfrom
zhangyue19921010:fix-scalar-optimize-noop-rewrite-final

Conversation

@zhangyue19921010
Copy link
Copy Markdown
Contributor

Summary

When optimize_indices was called on a scalar index in steady state (no unindexed fragments, and num_indices_to_merge <=1 ), the scalar branch of merge_indices_with_unindexed_frags still rebuilt the segment and assigned it a new UUID, churning the dataset version on every call. But in fact, the index content remains unchanged at all.

This adds the same no-op short-circuit that already exists for the Inverted branch: when unindexed is empty and num_indices_to_merge resolves to <= 1, return Ok(None) and skip the rewrite.

Behavior change

  • OptimizeOptions::default() / append() / merge(1) with no pending fragments is now a true no-op
    (UUID and manifest version are preserved).

Same as the logic in inverted index

        match index_type {
            IndexType::Inverted => {
                let num_to_merge = options
                    .num_indices_to_merge
                    .unwrap_or(1)
                    .min(old_indices.len());
                if unindexed.is_empty() && num_to_merge <= 1 {
                    return Ok(None);
                }

Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@github-actions github-actions Bot added the bug Something isn't working label May 22, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant