MongoDBBenchmark
Introducing AptMQL-Bench: A Text-to-MQL Benchmark
Summary
Large language models must reliably translate natural language requests into database query languages, but MQL, MongoDB’s query language, has lacked a dedicated benchmark. The authors introduce AptMQL-Bench, a Text-to-MQL benchmark derived from the BIRD Text-to-SQL dataset, comprising 21 MongoDB databases and 3,186 natural-language requests across domains like commerce and science. They present an agent-driven conversion pipeline that treats schema design as a first-class step, using access-pattern analysis to produce schemas that follow MongoDB’s golden rule of storing accessed-together data together. The pipeline includes automated validation checks and a second optimization pass that rewrote 45% of translated MQL queries to use embedded fields and precomputed aggregates. Evaluations of eight LLMs show the benchmark is challenging, with the best model (Claude Opus 4.5) achieving 70.34% soft execution accuracy with external knowledge, and the authors propose Soft-EX as a more appropriate metric for MQL than strict execution accuracy.
Context
Large language models must reliably translate natural language into database query languages, but MQL, MongoDB’s query language, lacked a dedicated benchmark. Existing Text-to-MQL approaches either start from native MongoDB data or mechanically convert Text-to-SQL datasets, but mechanical conversions are fragile: foreign key embedding can cause infinite recursion on self-referential keys, produce documents exceeding MongoDB’s 16 MB limit, or silently drop rows. These conversions also yield schemas with poor scalability.
Approach / What changed
The authors developed an agent-driven conversion pipeline with three stages: (1) access-pattern schema design, where an agent infers real-world application access patterns and designs a conceptual and logical schema following MongoDB’s golden rule; (2) migration and validation, with automated checks for data equivalence, reference integrity, and completeness, plus human review; (3) SQL-to-MQL translation with a second optimization pass that rewrote 45% of queries to use embedded fields and precomputed aggregates. The pipeline produced AptMQL-Bench from the BIRD Text-to-SQL dataset.
Takeaways
Mechanical conversion strategies like foreign key embedding can fail due to infinite recursion on self-referential keys or produce documents exceeding MongoDB’s 16 MB limit, and they can silently drop rows with up to 25.9% loss.
Access-pattern schema design yields MQL queries that run up to 77× faster than one-to-one migration on large databases, demonstrating the advantage of workload-driven schema design.
The proposed Soft-EX metric accepts predictions that return the same rows with matching values for gold fields, even if extra fields are present, which better suits MongoDB’s idiomatic document returns.
FAQ
What are the main challenges in converting Text-to-SQL datasets to MQL?
Mechanical denormalizations along foreign keys can be fragile. In experiments, three out of 24 databases failed to migrate due to infinite recursion on self-referential keys, three produced documents exceeding MongoDB's 16 MB limit, and eight databases experienced silent row loss reaching 25.9% in the worst case.
How does the conversion pipeline ensure schema quality?
The pipeline uses access-pattern analysis to design schemas that store accessed-together data together. Automated validation checks verify data equivalence, reference integrity, and completeness after migration, and a human reviewer works with the agent to fix any failures until all checks pass.
Why does the benchmark use Soft-EX instead of Strict-EX?
Strict-EX requires an exact field-for-field match, but returning extra fields is idiomatic in MongoDB. Soft-EX accepts predictions that return the same rows with matching values for every ground-truth field, allowing extra fields. This better reflects semantic correctness for MQL.
Source and freshness
- Source
- mongodb.com
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.