Storages: introduce trim min-max index for DATE/DATETIME/TIMESTAMP rough set filtering#10981
Storages: introduce trim min-max index for DATE/DATETIME/TIMESTAMP rough set filtering#10981JaySon-Huang wants to merge 7 commits into
Conversation
Signed-off-by: JaySon-Huang <tshent@qq.com>
Add ColumnStat field 105, pack-mark accessors, trim subfile naming, and default-off read/write settings so Readers can safely ignore or fall back without changing ordinary min-max behavior.
Build ordinary and trim indexes in one pack scan for V3 MyDate/MyDateTime columns, and persist .trim.idx only when trimmed outliers exist.
Normalize temporal ranges into DateRange, select trim indexes per DMFile stored E, and apply conservative low/high flag corrections in roughCheck.
|
Skipping CI for Draft Pull Request. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
dd5bd76 to
d142197
Compare
Prevent same-column OR branches from incorrectly sharing a loaded trim index when only some query domains are trim-eligible, avoiding false None pack pruning.
Gate trim range normalization behind dt_enable_trim_minmax_read, keep original operators when bounds cannot be parsed, and never return All for an empty DateRange domain.
d142197 to
0a5609f
Compare
| M(SettingFloat, dt_bg_gc_delta_delete_ratio_to_trigger_gc, 0.3, "Trigger segment's gc when the ratio of delta delete range to stable exceeds this ratio.") \ | ||
| M(SettingBool, dt_enable_logical_split, false, "Enable logical split or not in DeltaTree Engine.") \ | ||
| M(SettingBool, dt_enable_rough_set_filter, true, "Whether to parse where expression as Rough Set Index filter or not.") \ | ||
| M(SettingBool, dt_enable_trim_minmax, false, "Whether to generate and use trim min-max index for DATE/DATETIME/TIMESTAMP Rough Set filtering.") \ |
There was a problem hiding this comment.
default to false in master branch
Record trim min-max metrics only on Query reads after the cherry-pick left an undeclared read_tag reference on this branch's load() API.
backport #10982 to master branch
What problem does this PR solve?
Issue Number: close #10989
Problem Summary:
Applications sometimes use a far-future temporal value, such as
2100-01-01 00:00:00, as a sentinel for an unsettled record while normalDATE,DATETIME, orTIMESTAMPvalues remain concentrated in a recent range.Although such sentinels are sparse, they pollute the ordinary pack-level min-max index. With 8,192 rows per pack and an independently distributed sentinel probability of
1/10000, about 55.9% of packs contain at least one sentinel. Their ordinary maximum is extended to 2100, so narrow recent-time predicates cannot exclude those packs and must read and filter more data.The ordinary min-max index cannot simply ignore a particular application value because queries may intentionally access it. TiFlash needs an optional temporal index that improves pruning for eligible predicates without changing SQL semantics or weakening the ordinary fallback path.
What is changed and how it works?
This PR adds an optional pack-level trim min-max index for user
DATE,DATETIME, andTIMESTAMPcolumns in DeltaMerge DMFile V3 / MetaV2.The effective interval for format V1 is the half-open range
[1900-01-01 00:00:00, 2099-12-01 00:00:00). The ordinary min-max index remains unchanged and continues to cover every non-NULL, non-deleted value. The trim index covers only values inside the effective interval and records directional per-pack marks when values are trimmed below or above it.Write path and disk format
dt_enable_trim_minmax=true..idxpayload and its byte format unchanged.<column-stream>.trim.idxmerged subfile only when the DMFile contains trimmed outliers.ColumnStat.trim_minmax_index = 105.has_null, bit 1 ishas_trimmed_low, and bit 2 ishas_trimmed_high.Query-domain analysis and read path
Equal,IN, bounded ranges, and one-sided ranges.ANDrange bounds without sharing eligibility acrossORorNOTbranches.TIMESTAMPconstants through the request time zone into UTC-packed values before eligibility checks; compareDATETIMEandDATEusing calendar-value semantics.None -> SomeandAll -> Somewhen trimmed values can invalidate the uncorrected result.Configuration and observability
dt_enable_trim_minmaxsetting, defaulting tofalse. It controls both generation and query use of trim min-max indexes.All/Some/None/AllNullresults, and conservative correction counts.Compatibility
dt_enable_trim_minmaxrequires removing that unknown setting fromtiflash.tomlbefore startup.See the design document for the correctness proof, format details, and rollout constraints.
Check List
Tests
Unit coverage includes:
DATE, fractionalDATETIME, andTIMESTAMPpacked bounds and time-zone conversion;AND/ORtrees, and per-predicate eligibility;RSResultcorrection matrix, trim/ordinary pack-filter selection, missing attribute types, and DMFile MetaV2 persistence/drop behavior.The PR unit-test and integration-test CI jobs pass.
Manual validation used the same generated 500-million-row data set in two tables with different import/DMFile layouts:
test.bc_bet_records_500mandtest.bc_bet_records_500m_stream.All/Some/None,none_to_some, andall_to_some; the disabled run exercised onlyfallback_disabled. See the 500M correctness report.2,125.5 ms -> 1,613.2 ms) on the regular-import table and by 24.9% (2,066.3 ms -> 1,552.7 ms) on the stream-import table. P04 physical scanned rows decreased by 52.4% and 52.6%, respectively. The P05 outside-range control had unchanged scanned rows and no meaningful benefit, as expected. See the 500M benchmark report.5d56de051244ac7c893de5ac029f0013098f95dc, removed the unknowndt_enable_trim_minmaxsetting, and forced both tables through TiFlash MPP. Both 500-million-row invariant scans and complete Q01-Q33 suites passed with zero differences from the TiKV oracle, and no post-start DMFile/index/checksum/corruption error was logged. This validates read compatibility only; it does not cover old-version writes or metadata rewrites. See the downgrade report.The data generator, distributions, import paths, and SQL suites are documented in the dbgen trim min-max example.
Side effects
The feature is disabled by default. When enabled, DMFile writing performs additional min/max comparisons and may persist one optional trim subfile per eligible temporal column with outliers. Eligible reads load the trim index in preference to ordinary min-max; fallback queries retain the ordinary path.
Documentation
Release note
Summary by CodeRabbit
New Features
DATE,DATETIME, andTIMESTAMPdata.IN, and range predicates.Documentation
Tests