mongodb: fix the queries and the file the driver reads - #1174
Merged
Conversation
`benchmark.sh` pointed `BENCH_QUERIES_FILE` at `queries.txt`, which does not exist - the file
is `queries.sql` - so the driver read no queries at all.
`queries.sql` was derived from `queries.js` with `EJSON.stringify`, which turns a JavaScript
regular expression literal into an empty document. Q20 to Q23 therefore lost their predicate:
`{"$match": {"URL": /google/}}` was committed as `{"$match": {"URL": {}}}`, which matches
nothing. They are spelled as the Extended JSON `$regularExpression` now.
Two pipelines did not implement their SQL. Q37 filtered `URL <> ''` where the SQL filters
`Title <> ''` - a copy of the `$match` of Q36 - and Q28 left out the `MIN(Referer)` the SQL
selects and matched `(?:www.)?` where the SQL has `(?:www\.)?`.
A date was written as a bare calendar day, `{"$date": "2013-07-01"}`, which is not valid
Extended JSON; `mongosh` accepts it but other drivers refuse it. It is the full instant now.
`queries.js` is removed: `queries.sql` is the one file the benchmark and the playground read,
and keeping a second copy of the same pipelines by hand is what broke them.
alexey-milovidov
requested a deployment
to
benchmark-approval
August 1, 2026 02:07 — with
GitHub Actions
Waiting
Member
Author
|
We will merge without rerun. MongoDB is too slow. |
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.
Found while running the ClickBench MongoDB queries against the MongoDB compatibility layer of ClickHouse/ClickHouse#68493. Four independent defects, all in
mongodb/.benchmark.shreads a file that does not existThere is no
mongodb/queries.txt; the file isqueries.sql, and there never was aqueries.txtin this directory.bench_run_queryreads$BENCH_QUERIES_FILE, so the driver got no queries at all.Q20 to Q23 lost their predicate
queries.sqlwas derived fromqueries.jswithEJSON.stringify, which serializes a JavaScript regular expression literal as an empty document. Sowas committed as
{"$match":{"URL":{}}}which matches nothing —
{}is an equality test against the empty document. The four affected queries are Q20, Q21, Q22 and Q23; they now carry the Extended JSON$regularExpressionthatEJSON.parseinqueryturns back into a regular expression. On 33.7M rows ofhits, Q20 goes from an empty result to the 3979 rows the SQL returns.Q37 and Q28 did not implement their SQL
... AND DontCountHits = 0 AND IsRefresh = 0 AND Title <> '' GROUP BY Title, the pipeline filteredURL: {$ne: ""}. It is the$matchof Q36 with only the$groupchanged.k, AVG(length(Referer)), COUNT(*), MIN(Referer); the pipeline left outMIN(Referer). Its regular expression was also(?:www.)?where the SQL has(?:www\.)?, so an unescaped.matched any character.The dates are not valid Extended JSON
{"$date": "2013-07-01"}is a bare calendar day.mongoshaccepts it because it ends up innew Date(...), but Extended JSON asks for a full instant and other drivers reject it outright —pymongo'sjson_utilraisestime data '2013-07' does not match format '%Y-%m-%dT%H:%M:%S', which makes the 7 date-filtered queries unusable outsidemongosh. They are{"$date": "2013-07-01T00:00:00Z"}now, the same instant.queries.jsis removedqueries.sqlis the file the benchmark driver and the playground read. Keeping the same 43 pipelines a second time inqueries.jsand copying them across by hand is what dropped the regular expressions in the first place, so the copy is gone andREADME.mdpoints atqueries.sqlinstead.Verification
Every line of the new
queries.sqlwas run against a MongoDB wire protocol endpoint over 33.7M rows ofhitsand compared withclickhouse/queries.sqlon the same table. Q20, Q22, Q23, Q28 and Q37 now return exactly the values the SQL does, where before they returned nothing or the wrong ones. The queries that still differ are the ones that are not deterministic on this data — theyLIMITwithout a total order or cut through a run of ties, and their own SQL result changes between two identical runs — plus Q3, whereAVG(UserID)overflows in the SQL and the pipeline's$toDecimaldoes not, and Q26, where the pipeline projectsEventTimeon purpose so that the following$sortcan see it.The published results are now stale
Q20, Q21, Q22, Q23, Q28 and Q37 measured either nothing or the wrong work, so
mongodb/results/should be re-run. I do not have a MongoDB installation to do that on the reference hardware.