Repository navigation
perf(sql): reduce exact integer IN and NOT IN evaluation cost - #31257
Conversation
Use a bounded exact bitmap for dense sorted integer lists, retain the existing map construction for other sets, and avoid per-batch parameter wrappers. Skip membership work for NULL probes and preserve executor reset and selection semantics. Related to matrixorigin#31140.
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: fae1c51c99d187e09e279418501025b3728d5163
Assessment: approve
Reviewed the complete delta and caller lifecycle. The bounded bitmap and direct result writes preserve existing NULL, selection, fallback and query-reset contracts. The measured benefit justifies the added complexity; no actionable findings remain.
Model: gpt-6-astra / xhigh
Session: 01a1773b-d8e9-7ae1-9813-eff1ff7e3cab · slot 5 · generation 1
Validation:
-
Verified frozen HEAD, clean source and matching patch. Receipt/log reconciliation is retained in /home/xupeng/.local/state/mo-bot/jobs/b65f1bb8766f83a03d102660/attempt-4/validation-audit.json; design and coverage analysis is in review-record.json.
-
Isolation preflight passed. Rebuilt native prerequisites through repository make cgo using exact exported inputs; retained input/artifact hashes. Initial setup failures were resolved before tests.
-
Focused regressions and full pkg/sql/plan/function and pkg/sql/colexec tests passed. See focused-tests.log and package-tests.log with matching check receipts.
-
Native frontend SQL diagnostic passed dense/sparse/nullable membership, conditional selection, prepared-value refresh and UPDATE filtering. Diagnostic source, overlay, sql-probe.log and receipt are retained.
-
Repository-configured incremental lint passed with zero issues; formatting and diff checks passed.
-
Three-sample operator comparison against the frozen base registry: reused 4096-member/8192-row lookup median improved from 55.0 to 8.0 microseconds; construction-plus-probe allocation decreased from 76,368 to 1,120 bytes. Sparse controls improved overall; approximately 2% fresh one-row differences remain within shared-host measurement uncertainty.
Limitations:
-
The frozen bundle lacks linked issue #31140 text and traceable author validation artifacts. Approval covers the stated PR contract, without claiming closure of that broader issue.
-
SQL validation used one CN. Performance comparison isolates the operator; full TPC-H, mixed-I/O and concurrent-load performance remain outside the measured scope.
-
No new race run was required by the unchanged per-executor ownership model; author race-test claims were not counted as verified evidence.
What type of PR is this?
Which issue(s) this PR fixes:
Related to #31140
What this PR does / why we need it:
Reduce per-row hashing and per-batch allocation in exact integer IN/NOT IN evaluation. Sorted non-NULL integer lists with at least 16 members use an exact bitmap only when rounded backing fits both 64 KiB and eight bytes per input member; other sets reuse the existing map construction. Readiness and query-generation ownership remain with the existing expression executor.
Write preallocated boolean results directly, evaluate constant probes once, and skip membership work for NULL rows. Other type overloads and persisted formats are unchanged. Regression coverage includes all eight integer types, signed/unsigned extrema, NULL truth semantics, allocation bounds, selection masks, constants, and prepared-value refresh.
Validation against main
b466f4ae9b74:pkg/sql/plan/functionandpkg/sql/colexec: PASS.Local performance, serial runs on a shared machine, 262144 rows and three threads; paired warm medians for prepared filtering:
These minimal workloads improve by about 57–61%. The 4096-member/8192-probe operator benchmark reduces reused lookup time from about 87 to 12.5 microseconds and construction-plus-probe allocation from about 76 KB to 1.1 KB. Tiny fresh-set and sparse fallback controls were measured; a sparse all-NULL candidate regression was corrected and retained as regression coverage. No repeatable significant slowdown was found in tested controls; shared-host noise limits small-percentage conclusions.
DuckDB is v2.1.0-dev1 (
cc9648d736), using its C API versus MO over TCP and different physical plans. These results cover minimal exact-membership workloads, not complete TPC-H or general engine superiority. Full TPC-H, mixed-I/O and concurrent-load performance acceptance remain outside this PR's measured scope.