* 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>
* perf(mito2): prune files by their primary key range before reading footers
File-level pruning used only the manifest time range, so a scan read the footer of every file in the time range even when the file's primary key range excludes the predicate. The file-level pruning statistics now include the min and max of the first primary key column, decoded from FileMeta's primary key range, so such files are skipped without a footer read. For metric engine physical regions the first column is the table id.
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* test(mito2): cover file pruning by primary key range end to end
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* perf(mito2): decode the file primary key range only when pruning uses it
Predicates on the time index or fields never ask for the first primary
key column, so they no longer build a codec and two arrays per file.
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* fix(mito2): prune files by primary key ranges loaded from footers
Region open can fill a file handle's key range from the SST footer when
the manifest has none. Let the handle decide whether bounds are known,
so those files are pruned too.
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
* test: check file pruning by primary key range with EXPLAIN ANALYZE
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
---------
Signed-off-by: Dennis Zhuang <killme2008@gmail.com>