r/mongodb • u/rathboma • 16d ago
Does anyone actually use SQL with mongo?
I make a database app (https://beekeeperstudio.io), and we built our own SQL to mongo transpiler but frankly it's not as popular as I thought it would be.
I know mongo themselves have a SQL layer. Does anyone actually use it? If so, why use it over regular mongo queries?
4
Upvotes
2
u/DickBrainTime 16d ago edited 2d ago
I can see SQL being valuable here, but mostly as an interoperability/analysis interface rather than the primary way a MongoDB app reads and writes data. Someone doing a one-off investigation across collections, exporting a result to a report, or coming from BI/SQL tooling may already think in SELECT / WHERE / GROUP BY. An application developer who knows their document shapes can usually express the operation more directly with find() or an aggregation pipeline, and doesn't need an extra compatibility layer.
The tricky part for a transpiler is expectation mismatch: nested arrays, missing vs null fields, dynamic types, unwind/join behavior and MongoDB's $lookup don't have clean universal SQL equivalents. I'd rather see a clearly scoped, read-only SQL mode that exposes what aggregation it generated (and a warning for unsupported semantics) than a feature that silently looks like complete SQL compatibility. For product discovery, could you instrument which constructs people actually try in Beekeeper Studio and where they stop? A handful of reliable workflows like filtering, grouping and CSV export might matter more than full SQL syntax. Are your existing users asking for SQL over Mongo specifically, or are they mostly opening Mongo to browse JSON documents?
2
u/GromNaN 15d ago
One major reason for the SQL interface for MongoDB is for compatibility with analytics systems that connect through JDBC or ODBC. You donc create an application that uses MongoDB and query it using SQL, it's sub efficient and you will loose a lot a features.
1
u/xgerman1 12d ago
There is also the MongoDB API on SQL crowd (see https://documentdb.io/) - you cna use special SQL synaptic to execute document operations and otherwise use the Mongo protocol. That might be an alternative if SQL is important to you.
2
u/AxialDB 14d ago
From what we see, SQL-on-Mongo demand mostly isn't app CRUD. It shows up in three places: (1) BI tools that only speak JDBC/ODBC, (2) analysts who think in SQL doing one-off cross-collection investigations, and (3) people who need to join Mongo data with a relational DB. All three are read-only and analytical, so low usage inside a general client makes sense: those users often go straight to a BI connector.
Disclosure: we build AxialDB, which keeps MongoDB and MySQL data as live columnar tables so you can join them in one plain SQL query over JDBC/ODBC. https://axialdb.com/
1
u/my_byte 3d ago
Mongo guy here.
We have customers using atlas sql - in the cloud and on prem. The use case isn't and shouldn't be "I prefer the query language", that's silly.
The main reason why this is a vital capability for some customers is because they have existing tooling that is built to work with jdbc (mostly) and need they a way to plug Mongo into it to serve data. One good example is Celonis, a process mining software. In the past, things like PowerBI didn't have a native Mongo connector either. Plenty of software still doesn't.