Skip to content

Avoid q2 sorted per-row global-code remap - #3433

Draft
snissn wants to merge 2 commits into
mainfrom
codex/q2-lazy-global-rank-boundary-20260701
Draft

Avoid q2 sorted per-row global-code remap#3433
snissn wants to merge 2 commits into
mainfrom
codex/q2-lazy-global-rank-boundary-20260701

Conversation

@snissn

@snissn snissn commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • changes the q2 sorted grouped-distinct setup path to build dictionary-level local-code to global-rank maps instead of materializing per-row global-code arrays
  • translates local codes to global ranks at sorted iterator boundaries for heap ordering and reduction
  • keeps the existing q2 diagnostic field names for report compatibility, but the remap buckets now measure dictionary-level rank-map fill in this path

Scope / claim boundary

This is no-aggregate one-shot typed-column query setup work for q2 sorted grouped-distinct execution only. It is not metadata acceleration, and it should not be presented as ClickHouse superiority until current side-by-side evidence is regenerated.

The standard JSONBench full-prepared q2 path currently reports dense_group_count_distinct_used=true; that dense path remains separate and still uses its existing dense global-code/rank preparation. This PR is therefore still draft until we either attach a standard sorted-path acceptance artifact or explicitly decide to land it as a narrow sorted-path cleanup.

Evidence so far

Focused tests:

GOWORK=off go test ./TreeDB/collections -run 'TestTypedColumnQ2SortedGroupedDistinct|TestColumnPhysicalQueryDiagnosticsMerge' -count=1
GOWORK=off go test ./TreeDB/collections -run 'TestTypedColumnQ2' -count=1
GOWORK=off go test ./TreeDB/collections -count=1
git diff --check

All passed locally.

Exploratory 1M Bluesky sorted-path probe, using a temporary exported-API probe outside the repo:

  • patched setup: 530.284 ms
  • patched post-prepare: 178.488 ms
  • patched residual run: about 186.562 ms
  • patched wall total: 716.847 ms
  • origin/main setup: 716.148 ms
  • origin/main post-prepare: 242.269 ms
  • origin/main residual run: about 203.111 ms
  • origin/main wall total: 919.259 ms
  • rows scanned: 1,000,000
  • rows matched/reduced: 954,611
  • result hash: 3ff6801dd9b080cd on both runs

Standard JSONBench q2 1M one-shot/no-metadata artifact against this branch:

  • artifact: /tmp/jsonbench_q2_lazy_rank_1m_20260701_065655/report.json
  • layout: column-store-full-prepared
  • query mode: one_shot_end_to_end
  • metadata mode: no_aggregate_metadata
  • dense path: dense_group_count_distinct_used=true
  • setup: 45.715 ms
  • post-prepare: 20.480 ms
  • run: 18.119 ms
  • render/hash: 0.053 ms
  • total: 63.887 ms
  • rows scanned/matched/reduced: 1,000,000 / 954,611 / 954,611
  • result hash: b63b8e1013c918fcda7c299ef64beb20c4988854cf0671a83803b6951d795860
  • dense q2 split: group global rank 0.034 ms, distinct global rank 19.578 ms, part local rank 0.865 ms
  • dense distinct split: plan 0.001 ms, collect refs 7.768 ms, build shards 11.809 ms, refs 627,646, global ranks 180,100

This standard artifact is useful q2 context/no-regression evidence, but it does not prove the sorted grouped-distinct change because the standard path is dense.

Acceptance evidence still required before merge

  • standard sorted grouped-distinct q2 artifact, or an explicit decision to land this as a narrow sorted-path cleanup
  • preserve rows scanned/matched/reduced and result hash on the affected path
  • keep the standard dense q2 follow-up separate, targeting dense distinct rank/ref-build setup cost

Refs #3324
Refs #3070

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 4eff8262-0dcc-44d3-9356-ab4c895292c4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/q2-lazy-global-rank-boundary-20260701

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant