# MongoBench: Do LLMs Know What a MongoDB Query Will Do?

DevFeed: [MongoBench: Do LLMs Know What a MongoDB Query Will Do?](<https://devfeed.tech/articles/mongobench-do-llms-know-what-a-mongodb-query-will-do-124021.md>)

Original publisher: [Read original article](<https://arxiv.org/abs/2611.09065>)

Author: Qibai Chen, Haoting Qiu, Yezhou Cheng, Mengxiao Qian

Published: 2026-11-09T05:00:00Z

Content type: news

Language: en

Sources: [arXiv: Databases](<https://devfeed.tech/sources/arxiv-databases.md>), [arXiv: Software Engineering](<https://devfeed.tech/sources/arxiv-software-engineering.md>)

Topics: [MongoDB](<https://devfeed.tech/topics/mongodb.md>), [Ground truth / benchmark quality](<https://devfeed.tech/topics/ground-truth-benchmark-quality.md>), [Machine learning](<https://devfeed.tech/topics/machine-learning.md>)

Tags: [analysis](<https://devfeed.tech/tags/analysis.md>), [benchmark](<https://devfeed.tech/tags/benchmark.md>), [collection](<https://devfeed.tech/tags/collection.md>), [comparisons](<https://devfeed.tech/tags/comparisons.md>), [cs-db](<https://devfeed.tech/tags/cs-db.md>), [cs-se](<https://devfeed.tech/tags/cs-se.md>), [databases](<https://devfeed.tech/tags/databases.md>), [errors](<https://devfeed.tech/tags/errors.md>), [filter](<https://devfeed.tech/tags/filter.md>), [frontier](<https://devfeed.tech/tags/frontier.md>), [live-data](<https://devfeed.tech/tags/live-data.md>), [llm-agents](<https://devfeed.tech/tags/llm-agents.md>), [llms](<https://devfeed.tech/tags/llms.md>), [models](<https://devfeed.tech/tags/models.md>), [mongodb](<https://devfeed.tech/tags/mongodb.md>), [null](<https://devfeed.tech/tags/null.md>), [pitfalls](<https://devfeed.tech/tags/pitfalls.md>), [prediction](<https://devfeed.tech/tags/prediction.md>), [query](<https://devfeed.tech/tags/query.md>), [range](<https://devfeed.tech/tags/range.md>), [semantic](<https://devfeed.tech/tags/semantic.md>), [server](<https://devfeed.tech/tags/server.md>)

## AI overview

MongoBench measures whether a model can predict a MongoDB find() filter's effect before execution: given documents and a filter, it must identify the exact matching _ids, with ground truth from mongod. Its 300 items combine three or four documented matching pitfalls and were proposed by models from three vendors. Across four evaluated models, accuracy ranged from 70.1% to 92.1%; each proposer also mispredicted 10-31% of its own items. Errors tracked semantic pitfalls such as range comparisons and null more closely than document count or number of rules. A verified rule sheet helped unevenly. Executing a filter against the engine produced reliable match sets, but one model's delegated filters failed canonical checks on 28% of items on average across three runs; the other three passed every item. The authors release the benchmark, oracle, evaluation code, and prompts.

## Source excerpt

arXiv:2611.09065v1 Announce Type: new Abstract: LLM agents increasingly operate databases on their own: they generate queries and run them against live data. Two checks are commonly used to judge such an agent - whether it produces a valid query, and whether it reaches the right final answer - but neither tells us whether the agent knows what its query will actually do before it runs. We argue that this consequence prediction ability must be evaluated in its own right, and we build MongoBench to measure it: given a collection of documents and a MongoDB find() filter, a model must return the exact set of matching _ids, with ground truth from a real mongod server. The 300 items each compose three or four documented matching pitfalls and are proposed symmetrically by three vendors' models, so results stratify by item source. Evaluating four models - frontier systems from three vendors and one open-weight reasoner - accuracy ranges from 70.1% to 92.1%, a 22-point spread. Each proposer mispredicts 10-31% of the items it wrote itself, so producing a query does not imply predicting its effect. A failure-mode analysis shows errors are better predicted by which semantic pitfall a query exercises - range comparisons and null - than by surface measures such as document count or the number of composed rules. Prepending a verified rule sheet helps unevenly; executing the original filter against the engine yields reliable match sets, but delegation must be checked: on 28% of items (averaged over three runs) one model's executed filters never passed a canonical check against the intended query, and it answered about 22 of them wrong, while the other three passed on every item. We release the benchmark, the mongod oracle, and the evaluation code with all prompts at https://github.com/research-repo-bai/MongoBench.