Skip to content

fix: merge count(*)::numeric across shards - #1936

Open
murex971 wants to merge 2 commits into
mainfrom
fix-count-numeric-cast-merge
Open

murex971 wants to merge 2 commits into
mainfrom
fix-count-numeric-cast-merge

Conversation

@murex971

@murex971 murex971 commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Cross-shard count(*)::numeric failed with an invalid cast error: the parser treats a cast count as a count, but the merge only accepted integer and float partial counts.

Partial counts that come back as numeric are now converted to integers and summed, and the total is returned as numeric, the same as single-node Postgres.

@codecov

codecov Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@levkk

levkk commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Nice! We should add integration tests for this here: https://github.com/pgdogdev/pgdog/tree/bac0f8ea62e0ac73b871a0c06dd9c3224db81830/integration/sql

@jkaczman is also working on an acceptance test framework that compares the results returned by sharded and non-sharded pg, all the way to the binary protocol level, to ensure both are identical.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Metal bench (arm64) passed. All 152 measures within bounds.

suite throughput cpu/txn user cycles/txn user instr/txn kernel cycles/txn kernel instr/txn ctx/txn
pooler 20.02 (+0.2% ± 0.5%) 20,484 (+0.1% ± 0.4%) 35,285 (-0.0% ± 0.03%) 31,086 (+0.5% ± 0.8%) 51,876 (-0.0% ± 0.1%)
lb 20.59 (+0.2% ± 0.6%) 21,063 (-0.0% ± 0.3%) 36,197 (-0.0% ± 0.03%) 31,761 (+0.6% ± 1.0%) 53,060 (+0.0% ± 0.1%)
sharding-w2 38.3 (-0.6% ± 0.6%) 53,044 (-0.5% ± 1.0%) 102,575 (+0.0% ± 0.00%) 47,523 (-0.6% ± 1.1%) 54,286 (+0.0% ± 0.2%) 1.513 (+0.1% ± 0.2%)
sharding-w8 217,847 (+0.4% ± 0.4%) 33.66 (-0.3% ± 0.3%) 51,999 (+0.2% ± 0.4%) 57,890 (-0.0% ± 0.01%) 41,230 (-1.0% ± 0.3%) 42,923 (-0.0% ± 0.08%) 0.143 (-0.4% ± 1.7%)
Counters per txn
suite frontend stall l1i refill backend stall
pooler 8,454 (-0.0% ± 0.9%) 2,794 (+0.0% ± 0.3%)
lb 8,760 (+0.1% ± 0.6%) 2,853 (+0.3% ± 0.2%)
sharding-w2 24,593 (-1.6% ± 2.4%) 4,934 (-0.1% ± 1.5%)
sharding-w8 26,657 (+0.5% ± 0.9%) 4,793 (+0.4% ± 0.6%)

Microbench: all 135 measures within bounds.

lb flamegraph vs 3f7365a

lb

Open interactive for hover, zoom and search.

lb removed

Open interactive.

microbench flamegraph vs 3f7365a

microbench

Open interactive for hover, zoom and search.

microbench removed

Open interactive.

pooler flamegraph vs 3f7365a

pooler

Open interactive for hover, zoom and search.

pooler removed

Open interactive.

sharding-w2 flamegraph vs 3f7365a

sharding-w2

Open interactive for hover, zoom and search.

sharding-w2 removed

Open interactive.

sharding-w8 flamegraph vs 3f7365a

sharding-w8

Open interactive for hover, zoom and search.

sharding-w8 removed

Open interactive.

Logs

lb, microbench, pooler, sharding-w2, sharding-w8, verdict.json

Compared 1382fd8 with 3f7365a on m8gd.metal-24xl (spot).

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Metal bench (x86) passed. All 152 measures within bounds.

suite throughput cpu/txn user cycles/txn user instr/txn kernel cycles/txn kernel instr/txn ctx/txn
pooler 35.27 (+0.3% ± 0.3%) 24,835 (+0.9% ± 0.3%) 36,684 (-0.0% ± 0.01%) 57,478 (-0.0% ± 0.4%) 38,353 (-0.1% ± 0.1%)
lb 36.35 (+0.5% ± 0.2%) 26,156 (+1.8% ± 0.6%) 37,632 (-0.0% ± 0.02%) 58,443 (+0.1% ± 0.2%) 39,063 (-0.1% ± 0.1%)
sharding-w2 57.85 (+0.7% ± 0.4%) 56,755 (+1.2% ± 0.6%) 106,017 (-0.0% ± 0.01%) 72,942 (+0.5% ± 1.0%) 43,127 (-0.0% ± 0.2%) 1.384 (-0.2% ± 0.1%)
sharding-w8 143,007 (-1.2% ± 0.4%) 49.89 (+0.3% ± 0.4%) 62,517 (+0.4% ± 0.2%) 61,421 (+0.0% ± 0.05%) 64,409 (+0.1% ± 0.8%) 34,254 (+0.1% ± 0.09%) 0.1567 (-0.2% ± 1.0%)
Counters per txn
suite frontend stall l1i refill backend stall
pooler 79,075 (+2.5% ± 0.5%) 3,847 (+2.4% ± 0.1%)
lb 83,270 (+3.8% ± 1.0%) 3,985 (+3.0% ± 0.2%)
sharding-w2 169,736 (+2.7% ± 0.9%) 6,293 (+1.6% ± 0.4%)
sharding-w8 138,259 (+2.8% ± 0.6%) 5,132 (+1.5% ± 0.2%)

Microbench: all 135 measures within bounds.

lb flamegraph vs 3f7365a

lb

Open interactive for hover, zoom and search.

lb removed

Open interactive.

microbench flamegraph vs 3f7365a

microbench

Open interactive for hover, zoom and search.

microbench removed

Open interactive.

pooler flamegraph vs 3f7365a

pooler

Open interactive for hover, zoom and search.

pooler removed

Open interactive.

sharding-w2 flamegraph vs 3f7365a

sharding-w2

Open interactive for hover, zoom and search.

sharding-w2 removed

Open interactive.

sharding-w8 flamegraph vs 3f7365a

sharding-w8

Open interactive for hover, zoom and search.

sharding-w8 removed

Open interactive.

Logs

lb, microbench, pooler, sharding-w2, sharding-w8, verdict.json

Compared 1382fd8 with 3f7365a on m7a.metal-48xl (spot).

@murex971
murex971 requested a review from levkk November 2, 2026 19:42

This branch has not been deployed

No deployments
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.

2 participants