Skip to content

do not report exact scanner row counts for legacy SSTs with unknown num_rows #9718

Closed

Description

@discord9

What type of bug is this?

Incorrect result

What subsystems are affected?

Storage Engine, Query Engine, Table Engine

Minimal reproduce step

This issue was identified by source inspection. A focused regression test can reproduce it without a full SQL deployment:

  1. Create an append-mode Mito scan with a nonempty SST whose legacy FileMeta has no serialized num_rows field. For example, serialize a valid FileMeta, remove num_rows, and deserialize it; the field defaults to 0 (unknown).
  2. Use an unfiltered scan with no region partition expression and no other visibility restrictions.
  3. Observe the results of ScanInput::total_rows() and ScanInput::total_rows_is_exact() for the selected SST.
  4. Check the row-count statistics exposed through ScannerProperties and RegionScanExec::statistics_from_inputs() to DataFusion.

Suggested regression coverage:

  • All selected SST row counts are known.
  • A mix of known-count and unknown-count SSTs.
  • An unknown-count SST together with a memtable.
  • An unknown-count SST pruned by the query's time range (it should not affect the selected scan's precision).
  • A non-append-mode scan, whose statistics must retain their existing conservative behavior.

What did you expect to see?

If any selected SST has an unknown row count, the scanner must not report an exact total row count. DataFusion should receive unknown/non-exact row-count statistics rather than Precision::Exact. The ordinary scan must still read the SST and return the correct rows.

If all selected SST counts are known and the existing visibility conditions hold, preserve the current exact-statistics behavior.

The fix should be narrowly scoped to the existing scan-statistics contract. It does not require a new COUNT optimization, Parquet footer recovery, a new statistics abstraction, or a CBO rule.

What did you see instead?

The current code appears to report an exact row count even when the count of a selected legacy SST is unknown:

This is a source-level finding; the end-to-end incorrect-result scenario has not yet been reproduced.

What operating system did you use?

Not applicable (identified by source inspection).

What version of GreptimeDB did you use?

main at baa5630119341a8ffc173dd49571917c09df5123 (source inspection).

Relevant log output and stack trace

None. No runtime reproduction or stack trace collected yet.

Activity

  1. changed the title [-]fix(mito2): do not report exact scanner row counts for legacy SSTs with unknown num_rows[/-] [+]do not report exact scanner row counts for legacy SSTs with unknown num_rows[/+] on Oct 19, 2026
  2. Aumnertic commented on Oct 19, 2026

    @Aumnertic
    Contributor

    I'd like to work on this issue.

    I'll start by adding regression tests for legacy SSTs with unknown num_rows, then fix the scanner statistics so that unknown row counts are not reported as exact, while preserving normal scan behavior.

  3. added a commit that references this issue on Oct 20, 2026
    6f53d57
  4. added 4 commits that reference this issue on Oct 27, 2026
    7639711
    eabf464
    b10a4fb
    badceec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory Bugs

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions