Files
greptimedb/tests
dennis zhuang b26b87f914 perf(mito2): split seq scan ranges of files with disjoint primary keys (#10561)
* perf(mito2): split seq scan ranges of files with disjoint primary keys

Seq scan merged every SST whose time range overlapped another into one
partition range. Compaction outputs split by max_output_file_size cover
the same time range with disjoint primary keys, so a compacted window was
read and deduplicated by a single partition.

Ranges are now merged only when both their time ranges and their
primary key ranges overlap. Memtables and files without key statistics
still overlap every key.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* perf(mito2): index open seq scan groups by primary key

Grouping compared each range with every open group, so n files with
disjoint keys in one time window took n(n-1) checks. Open groups now
sit in a BTreeMap keyed by their min primary key; their key ranges are
disjoint, so one range lookup finds every group to merge. Groups that
ended before the current range are closed when a lookup reaches them.

Per-series scans keep grouping ranges by time only.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* perf(mito2): merge the smaller seq scan range into the larger one

A range that joined many groups, such as a memtable overlapping many
files with disjoint keys, was appended to each group in turn and copied
its growing index lists every time. Merges now append the smaller range
to the larger one, so each index is copied O(log n) times.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* docs(mito2): clarify the seq scan grouping invariant and lookup cutoff

State that grouping keeps every version of a (primary key, timestamp)
pair together, instead of "ranges in different groups never share a
key", which read as if one key could not appear in two groups. Explain
why the reverse BTreeMap walk can stop early: disjoint key ranges order
their upper bounds the same as their lower bounds.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* fix(mito2): split seq scan ranges by primary key only without a distribution

TimeWindowed scans advertise (ts, primary key) ordering. Key-disjoint
ranges that partition assignment reorders inside one partition would not
keep it, so scans with any distribution keep grouping ranges by time.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* docs(mito2): state that SeqScan does not keep the TimeWindowed ordering today

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* fix(mito2): locate the primary key column by its top-level path

A nested field such as a JSON child named __primary_key has the same leaf name and comes first, so the bounds and the primary key projection could read the wrong column.

Closes #10582

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* refactor(mito2): rename files_time_range_pruned to files_manifest_pruned

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

---------

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-11-23 12:48:21 +00:00
..

Sqlness Test

Sqlness manual

Case file

Sqlness has two types of file:

  • .sql: test input, SQL only
  • .result: expected test output, SQL and its results

.result is the output (execution result) file. If you see .result files is changed, it means this test gets a different result and indicates it fails. You should check change logs to solve the problem.

You only need to write test SQL in .sql file, and run the test.

Case organization

The root dir of input cases is tests/cases. It contains several subdirectories stand for different test modes. E.g., standalone/ contains all the tests to run under greptimedb standalone start mode.

Under the first level of subdirectory (e.g. the cases/standalone), you can organize your cases as you like. Sqlness walks through every file recursively and runs them.

Kafka WAL

Sqlness supports Kafka WAL. You can either provide a Kafka cluster or let sqlness to start one for you.

To run test with kafka, you need to pass the option -w kafka. If no other options are provided, sqlness will use conf/kafka-cluster.yml to start a Kafka cluster. This requires docker and docker-compose commands in your environment.

Otherwise, you can additionally pass the your existing kafka environment to sqlness with -k option. E.g.:

cargo sqlness bare -w kafka -k localhost:9092

In this case, sqlness will not start its own kafka cluster and the one you provided instead.

Run the test

Unlike other tests, this harness is in a binary target form. You can run it with:

cargo sqlness bare

It automatically finishes the following procedures: compile GreptimeDB, start it, grab tests and feed it to the server, then collect and compare the results. You only need to check if the .result files are changed. If not, congratulations, the test is passed 🥳!