When you’re building apps, the query language you work with makes a big difference. It affects everything from performance to how quickly your team can ship features. In this post, I’ve asked an LLM to create a list of 21 ranked criteria that are most valuable when deciding which query language to use. We’ll walk through each one and show how SQL++, used by Couchbase, and Mongo’s Query API (previously known as MQL) languages stack up.

Whether you’re evaluating databases for a new project, or just curious about the differences between these two approaches, this should give you a clear picture of where each one shines and where it might fall short.

Expressiveness

SQL++ lets you write rich, complex queries—joins, subqueries, aggregates, window functions—while working with flexible document data. You can express nearly anything you’d expect in SQL, plus native support for JSON.

Mongo’s query language is more limited. You can do a lot with the aggregation pipeline, but expressing multi-collection joins or deep subqueries can become verbose and may require workarounds or advanced pipeline constructs.

SQL++ Mongo
Mongo requires a more procedural pipeline:

Readability

SQL++ is declarative and familiar to anyone with SQL experience. The intent of the query is easy to see.

Mongo’s pipeline is more verbose and procedural—you have to mentally step through each stage.

For simple queries this isn’t terrible. But as queries grow (joins, subqueries, aggregations), readability can drop quickly in Mongo’s pipeline format.

Consistency

SQL++ is highly consistent. The syntax and semantics are predictable, and it feels like “SQL for documents” across the board.

Example with nested data:

In Mongo, querying nested structures often requires switching to dot notation or array operators, and pipelines use a different style than find(). You end up learning multiple syntaxes:

Simple query with dot notation:

More complex? You’re back in aggregation-land:

Performance

When it comes to raw performance, Couchbase SQL++ consistently outpaces MongoDB’s query language in benchmarks, especially under high-throughput, low-latency workloads.

Couchbase has demonstrated superior scalability and efficiency in various benchmarks. For instance, in the Yahoo! Cloud Serving Benchmark (YCSB), Couchbase exhibited significantly better performance at scale—up compared to MongoDB.

Beyond benchmarks, Couchbase customers have reported significant performance improvements:

MongoDB’s latest release, while improving over its previous versions, still lags behind in certain scenarios. MongoDB 8.0 introduced performance enhancements, achieving faster mixed read/write workloads compared to MongoDB 7.0. However, these improvements are relative to its own prior performance and may not match the scalability and speed demonstrated by Couchbase in independent benchmarks (like the BenchANT Database Ranking).

Index Support

SQL++ supports a broad set of indexes: primary, secondary, composite, array, partial, covering, FTS—all usable from a single language.

Mongo supports primary (on _id), secondary, compound, multikey, text, and hashed indexes. It’s strong, but lacks some of the flexibility of SQL++ when it comes to indexing deeply nested fields or expressions.

Example with partial index in SQL++:

Mongo partial index is similar:

Join Capabilities

SQL++ supports full JOIN syntax—inner, left outer, UNNEST, and combinations. It treats documents as first-class citizens in relational-style queries.

Example:

Mongo’s $lookup supports more expressive pipelines since 5.0, but is still LEFT OUTER and lacks full join syntax.

SQL++ also supports multiple joins and joins on expressions—Mongo’s $lookup is more limited in comparison.

Aggregation Support

SQL++ has full GROUP BY, HAVING, window functions, and flexible expressions—just like standard SQL.

Example:

Mongo’s aggregation pipeline is capable, but more procedural. You chain stages like $group, $match, $project, etc.:

Both are powerful, but SQL++ is typically more concise and familiar for SQL users, and supports features like window functions that Mongo’s pipeline lacks.

Filtering and Predicate Logic

SQL++ has full support for complex filtering with AND, OR, NOT, BETWEEN, IN, subqueries, and arbitrary expressions.

Example:

Mongo supports filtering in find() and in $match stages, but the syntax is more verbose and JSON-based:

Both can express complex predicates, but SQL++ tends to be more readable for highly complex boolean logic.

Subquery Support

SQL++ supports full subqueries: correlated, uncorrelated, scalar, EXISTS/NOT EXISTS—all the patterns you’d expect.

Example:

Mongo doesn’t support subqueries in the same way. You generally have to rewrite using $lookup, $facet, or multiple queries in application code. This is one area where SQL++ is much stronger and more natural.

Data Manipulation Support

SQL++ supports full INSERT, UPDATE, DELETE, MERGE — all standard data manipulation operations.

Example UPDATE:

Mongo also supports data manipulation via insertOne, insertMany, updateOne, updateMany, deleteOne, deleteMany, and replaceOne. The functionality is solid, but operations are separate API calls—not unified under one query language.

Example update:

Both are capable, but SQL++ provides a single, consistent language for both querying and modifying data.

Transactions Support

SQL++ supports multi-statement ACID transactions (with Couchbase’s BEGIN TRANSACTION, COMMIT, ROLLBACK), and transactions can span multiple documents, collections, and even multiple statements.

Example:

Mongo introduced multi-document ACID transactions in version 4.0. They are supported, but must be initiated from drivers using a session object, or mongosh, not part of the Mongo query language itself.

Example (driver-based in Node.js):

Summary: Both support ACID transactions, but SQL++ lets you express them declaratively inside the query language itself, which is easier and clearer.

Error Handling

SQL++ surfaces structured error codes and messages to the client when a query fails — these are accessible through the SDKs and query metadata. You can also write queries defensively (e.g. IF EXISTS, IF MISSING, CASE expressions) to control behavior.

Example (defensive logic):

Error codes are documented here: Couchbase SQL++ Error Codes.

Mongo also relies on driver-level error handling — errors are raised to the client when queries or commands fail. Mongo’s aggregation pipeline does not support in-query error handling either.

Example (Mongo defensive update):

Summary: Both SQL++ and Mongo rely on external (driver-level) error handling. You can use defensive query patterns to mitigate common errors.

Extensibility

SQL++ allows user-defined functions (UDFs) written in SQL++ itself. These can encapsulate complex logic, reuse expressions, and simplify queries.

Example UDF:

Usage:

Mongo has no in-query UDFs in its query language or aggregation pipeline. You can use $function (introduced in MongoDB 4.4), which lets you run JavaScript functions inside aggregation — but this is less efficient and limited in portability:

Summary: SQL++ UDFs are native, efficient, and portable; Mongo’s $function uses JavaScript and may have performance trade-offs.

Declarative Nature

SQL++ is fully declarative — you express what you want, not how to compute it. You rely on the query optimizer to determine the best execution plan. This makes queries simpler to write and maintain.

Mongo’s aggregation pipeline is more procedural — you specify the exact sequence of operations ($match, $group, $project, $sort, etc.). For complex logic, this often requires thinking in terms of data flow, not desired result.

Portability

SQL++ is based on SQL with JSON extensions. If you know SQL, it’s easy to learn SQL++, and much of your knowledge carries over. The language is also designed to be portable across Couchbase deployments — cloud, self-managed, edge.

Mongo’s query language is specific to MongoDB. Its syntax is JSON-based, not SQL-like, and most of it doesn’t transfer to other databases. While it’s great inside the Mongo ecosystem, it’s harder to port to systems like relational databases, Couchbase, or cloud data warehouses.

Pagination Support

SQL++ supports pagination using LIMIT and OFFSET — standard SQL-style:

Mongo also supports pagination with .limit() and .skip():

Both handle basic pagination well.

However — SQL++ also supports window functions (e.g. ROW_NUMBER() OVER (…​)), which allows for more advanced pagination and cursor-based patterns, whereas Mongo requires additional pipeline stages or application logic to simulate those.

Schema Introspection

SQL++ / Couchbase supports automatic schema discovery via the INFER command. Since Couchbase is schema-flexible, INFER lets you analyze documents in a collection and generate a probabilistic schema — showing what fields exist, their types, nesting, and occurrence percentages.

Example:

Returns information about the airline collection, including field names, types, and occurrence percentages:

Mongo has no direct query language equivalent to INFER, though MongoDB Atlas offers Schema Explorer in the UI.

Closest options:

    • db.collection.aggregate([ { $sample: { size: N } } ]) + manual inspection
    • Third-party tools

Tooling and IDE Support

SQL++ is supported in:

    • Couchbase Web UI Query Workbench
    • VS Code SQL++ extension
    • JetBrains IDEs (plugin)
    • REST API / CLI
    • Couchbase Shell

Mongo’s tooling includes:

    • MongoDB Compass (GUI)
    • Mongo Shell / mongosh
    • MongoDB Atlas UI
    • VS Code MongoDB extension

There are other tools as well. Both have good tooling. SQL++ integrates better with SQL-friendly tools (DataGrip, BI tools, etc.). Mongo tools are more Mongo-specific.

Community and Documentation

SQL++ / Couchbase:

    • Official Docs: Couchbase SQL++ Reference
    • Active Couchbase developer community
    • Blogs, forums, Stack Overflow, Discord
    • SQL++ is based on familiar SQL, so existing SQL resources also apply

Mongo:

    • Official Docs: MongoDB Query Language Reference
    • Large community
    • Many tutorials, courses, books
    • Heavily used in web dev / JavaScript communities

Mongo has a bigger community (simply due to broader adoption), but SQL++ benefits from SQL familiarity and an increasingly active Couchbase developer ecosystem.

Integration with App Frameworks

SQL++ / Couchbase is supported via:

    • SDKs in major languages: Java, .NET (C#), Node.js, Python, Go, C++, Scala
    • ODBC / JDBC drivers → works with BI tools (Tableau, Power BI, Excel, Looker)
    • REST API
    • A growing ecosystem of integrations, including Spring Data, EF Core, Quarkus, and more

Mongo has:

    • Official drivers for nearly every major language
    • Strong ecosystem for developers

Mongo has a larger ecosystem, but SQL++ is more familiar to SQL developers in general.

Standards Compliance

SQL++ is a SQL-derived language:

    • Based on ANSI SQL with extensions for JSON documents, arrays, nesting
    • You can take standard SQL skills and use them right away
    • Many existing SQL-based tools and patterns apply

Mongo’s query language is non-standard:

    • Based on JSON syntax and operators
    • No direct mapping to ANSI SQL
    • Requires learning Mongo-specific query patterns

If you want SQL compatibility and standards alignment, look to SQL++. If you’re fine with a Mongo-specific language, Mongo’s approach works, but is harder to port.


Summary

SQL++ is a natural fit for developers familiar with SQL. It’s a superset of SQL, so existing SQL knowledge carries over.

MongoDB’s query language is more specialized and procedural, which can be powerful but also requires a different mindset.

Here’s the complete criteria listing:

Rank Name of Criteria How to Apply It Why It’s Important
1 Expressiveness Assess how many types of queries can be written Determines flexibility in handling data tasks
2 Readability Review sample queries for clarity Impacts learning curve and maintenance
3 Consistency Look for consistent syntax and semantics Reduces bugs and surprises
4 Performance Benchmark query execution on real workloads Affects speed and scalability
5 Index Support Check range of index types and usage options Critical for optimizing query speed
6 Join Capabilities Test support for different join types Key for working with related data
7 Aggregation Support Evaluate support for grouping and aggregation Necessary for analytics and reporting
8 Filtering and Predicate Logic Test complex WHERE and HAVING clauses Enables precise data retrieval
9 Subquery Support Verify support for correlated and nested subqueries Adds depth to querying
10 Data Manipulation Support Test INSERT, UPDATE, DELETE, MERGE functionality Important for data maintenance
11 Transactions Support Check support for multi-statement transactions Ensures data consistency and atomicity
12 Error Handling Review mechanisms for detecting and reporting errors Helps with debugging and reliability
13 Extensibility Check ability to add user-defined functions (UDFs) Allows customization for advanced needs
14 Declarative Nature Determine if the language specifies what to do, not how Simplifies development and optimization
15 Portability See how easily queries migrate across systems Reduces vendor lock-in and aids flexibility
16 Pagination Support Test LIMIT, OFFSET, or windowing support Critical for APIs and UI-driven data access
17 Schema Introspection Check querying of schema/catalog metadata Supports automation and tooling
18 Tooling and IDE Support Survey ecosystem of query editors, plugins, etc. Impacts developer productivity
19 Community and Documentation Review quality of docs, community forums, tutorials Affects ease of learning and troubleshooting
20 Integration with App Frameworks Check library and driver support in popular languages Eases app development
21 Standards Compliance Compare with industry standards (e.g. SQL) Helps with portability and interoperability

 

Author

Posted by Matthew Groves

Matthew D. Groves is a guy who loves to code. It doesn't matter if it's C#, jQuery, or PHP: he'll submit pull requests for anything. He has been coding professionally ever since he wrote a QuickBASIC point-of-sale app for his parent's pizza shop back in the 90s. He currently works as a Senior Product Marketing Manager for Couchbase. His free time is spent with his family, watching the Reds, and getting involved in the developer community. He is the author of AOP in .NET, Pro Microservices in .NET, a Pluralsight author, and a Microsoft MVP.

Leave a reply