Repository navigation
Add _id range, keyset pagination, ObjectId and UUID insert benchmarks - #67
Merged
Merged
Conversation
macneale4
marked this pull request as ready for review
November 6, 2026 22:09
Collaborator
Author
|
Code Review Feedback: https://claude.ai/artifact/H13SbhP3hLitrb1BnscYxq |
Find_IdRange_{Int,String,ObjectId} find a sliding window of n/100
consecutive _ids, and Find_IdPaginate times one page of
{_id: {$gt: last}} sorted on _id with a limit of 100. Each checks its
results and _id_ index use before timing; DumboDB's full scan is
declared as a known gap tracked by dolthub/dumbodb#207.
Known gaps elsewhere in benchmarks/ now cite their dolthub/dumbodb
issues instead of internal tracker ids, and comments and README text
state what those ids referred to.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On a clustered collection, mongod and DumboDB explain an _id range as CLUSTERED_IXSCAN with no indexName, and read documents without index keys. Count that as reading _id_, and keep only the documents-read bound for it in the reads check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
InsertOne_ObjectId and InsertMany_ObjectId_{100,1000} match the existing
inserts except for fresh driver ObjectIds, which increase as server
generated ids do, so the pair shows whether _id order changes insert
cost.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Find_IdRange_UUID_{10K,50K} joins the _id range family with BSON binary
subtype 4 keys. InsertMany_{UUIDv4,UUIDv7,UUIDv4String}_50K_{100,1000}
insert into a collection seeded with 50K documents of the same _id kind,
contrasting random keys, increasing keys, and UUIDs stored as strings.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
macneale4
force-pushed
the
macneale4/benchmark-id-range
branch
from
November 6, 2026 22:46
00f57e0 to
7fea312
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds benchmarks for
_idranges, keyset pagination on_id, inserts with increasing ObjectId_ids, and UUID_idranges and inserts. Also teaches the index-use check to recognize clustered_idscans, which dolthub/dumbodb#209 introduces.New benchmarks
Find_IdRange_{Int,String,ObjectId,UUID}_{10K,50K}: find a window of n/100 consecutive_ids ($gte/$lt), moving the window each iteration. Before timing, checks the result count.Find_IdPaginate_{10K,50K}: one page of{_id: {$gt: last}}, sorted on_id, limit 100, walking the whole collection. Before timing, checks the exact page of_ids in order.InsertOne_ObjectId,InsertMany_ObjectId_{100,1000}: the same asInsertOne/InsertManybut with fresh driver ObjectIds. These increase as server-generated ids do, so each pair shows whether_idorder changes insert cost. The existing insert benchmarks still send the same string ids.InsertMany_{UUIDv4,UUIDv7,UUIDv4String}_50K_{100,1000}: insert batches into a collection seeded with 50K documents of the same_idkind, so each insert lands among existing keys. Binary (subtype 4) v4 UUIDs are random, v7 UUIDs increase, andUUIDv4Stringstores v4 UUIDs as 36-character strings. Before timing, each checks that the stored_idreally has the intended type.The
_idbenchmarks require the_id_index on MongoDB. On DumboDB the full scan is declared as a known gap tracked by dolthub/dumbodb#207, so they pass against the current release.Clustered
_idscansOn a clustered collection, mongod and DumboDB (after #209) explain an
_idrange asCLUSTERED_IXSCANwith noindexName, and they read documents without index keys. The index-use check now counts that as reading_id_. For those scans it skips the "documents read <= index keys" rule but keeps the "documents read <= max(returned, n/10)" bound, so a full scan still fails.Against #209's head (
3fc21702), the_idbenchmarks fail with "promote this benchmark to mustUseIndex", the intended signal. WithidOrderGapset tomustUseIndex, all of them pass on both servers, including thequeryExecutorread counters. After #209 merges, changeidOrderGaptomustUseIndexinbenchmarks/id_range_scaled_bench_test.go.Tracker ids removed from benchmarks/
Known gaps in
benchmarks/now cite their dolthub/dumbodb issues instead of internal tracker ids: #143 (_idlookups explain as COLLSCAN), #144 ($lookupforeign index missing from explain), #142 (covered projections fetch documents) and #139 (range over half the collection). The inline duplicate of the #139 gap now reuseshalfCollectionCapGap. The README and thecmd/comparecomments state what their ids referred to or drop them; the README names dumbodb'sTestSeekScaling_PointLookupIsLogarithmicin place of the old reference. This is folded into the first commit.Results
Local
mongod8.0.28 and local DumboDB builds, run throughcmd/compare -dumbodb-bin/-mongod-bin. Times are ms/op; before is dumbodb5b7a9f71(main), after is3fc21702(#209). The_idrange rows are single 2s runs. The insert rows are the median of 3 runs of 3s each; the repetitions were within about 3% of each other, apart from one outlier per build._idranges and paginationInserts into an empty collection
Inserts into a 50K collection
_idkind, because the hashed primary key scatters every insert. After #209, inserts with increasing keys (ObjectId, UUIDv7, and the batch-contiguousiter-<i>-<j>strings) get 1.6-3.6x faster. Random UUIDv4 keys gain only about 5% and stay 3-4x slower than MongoDB, which loses only about 12% to random keys at a batch of 1000.Testing
go vet ./...,gofmtcmd/compareagainst both builds above and MongoDB 8.0.28.🤖 Generated with Claude Code