r/mongodb • u/szerina • 9h ago
r/mongodb • u/Aromatic-Departure17 • 15h ago
Inspecting a MongoDB aggregation one stage at a time
reddit.comr/mongodb • u/Aromatic-Departure17 • 15h ago
Reading MongoDB aggregation Explain output with a small before-and-after example
reddit.comr/mongodb • u/Aromatic-Departure17 • 15h ago
Copying a MongoDB collection with JSON Lines and handling duplicate IDs
reddit.comr/mongodb • u/Aromatic-Departure17 • 15h ago
Finding duplicate MongoDB values before adding a unique index
reddit.comr/mongodb • u/Aromatic-Departure17 • 15h ago
MongoDB found two orders with the same external ID. How do I see both documents?
reddit.comr/mongodb • u/Fun-Chicken6946 • 2d ago
A new way to practice MongoDB online for free: LeetCode-style problems with hidden test cases
Hi everyone! I've spent months building a free website for practicing MongoDB, and I wanted to share it with the community.
One thing I noticed when learning MongoDB was that there weren't many places where you could actually practice writing queries and have your solutions tested, similar to how LeetCode works. So I decided to build one. As far as I know, it's the first of its kind.
Most MongoDB practice sites just parse your query or compare it to a fixed answer. This one runs a real MongoDB-compatible database right in your browser, so you can do what you'd do in a real shell: create collections, insert and update documents, build indexes, run aggregation pipelines and check explain plans. Your code is executed and validated against hidden test cases.
What you can do:
- Practice MongoDB directly in your browser, with no install and no sign-up.
- Write real find, aggregate, and createIndex code with mongosh syntax. (even $search)
- Work through 30 MongoDB interview questions, from Medium to Expert: joins, grouping, arrays, schema drift, geo queries and window functions.
- Test your solutions against multiple hidden datasets, so queries that only work on the sample data get caught.
- Practice query optimization, with performance questions graded on your explain plan.
All the problems and their solutions have been verified against MongoDB 8.
Getting all of this to run entirely in your browser, with no server behind it, took months of work, and your queries never leave your machine.
It's completely free, and I'd love to hear what you think, especially if there are MongoDB concepts or challenges you'd like me to add.
r/mongodb • u/Vamshi__4555 • 3d ago
Mongodb Data Compression
Hey guys we are using mongodb as our main db with 3 nodes replica .Each node of almost 20 TB disc with default snappy compressor ,recently we went with encryption of PI DATA on each node .Before encryption disc sizes was almost 13 TB on each node .After encryption it back to 20 TB .So to reduce cost we are planning of using ZTSD compression on each node it can reduce upto 20 -30 percent on each node ,but the problem is the data is already encrypted ,so can we compress the encrypted data on the disc ,as it can reduce the size or any other alternatives…?
Mostly in every collection we have PI data ,as the company’s business is lending business….
r/mongodb • u/gokhanozgezer • 5d ago
I built a self-hosted, browser-based MongoDB manager for teams (open source, AGPL-3.0)
Hi r/mongodb! Compass is a great tool, but it's built for one person on one laptop. I wanted something my whole team could use from a browser, running on our own server, with roles, an audit log and backups built in. So I built Mongo Manager.
GitHub: https://github.com/mongo-manager/mongo-manager
What it does for MongoDB specifically:
- Query plans: explain output as a tree with warnings, and a suggested index prefilled ("why is it slow?"). On sharded clusters it shows each shard's plan.
- Aggregation builder: stage cards with a live preview of each stage on a sample;
$out/$mergeonly run after a confirmation. Pipelines export to Node.js, Python, Java, Go, C#, PHP, Ruby and Rust. - Indexes: every type and option,
$indexStatsusage, plus Atlas Search and Vector Search indexes. - Schema analysis: field types, frequency and value histograms; generate validation rules from a sample and test them against existing documents.
- Replica sets: member status and replication lag with 7 days of history, lag alerts, and change streams with filters and pre-images.
- Sharding: chunk distribution per shard, zones, balancer windows, and a shard key check before you shard a collection.
- Live sync: a continuous, verified copy between connections, ending with a cutover.
- Backups: mongodump archives or encrypted files, scheduled, to S3, Google Drive, WebDAV or a local folder; restores get a dry run first.
- Auth: SCRAM, X.509, LDAP, AWS IAM, OIDC, Kerberos, SSH tunnels; CSFLE and Queryable Encryption.
For teams: admin/editor/viewer roles, access per connection, 2FA, a hash-chained audit log, and rule-based masking of personal data.
Try it: npx @mongo-manager/app (Node 24+), Docker, or a standalone binary. Supports MongoDB 6.0+, Atlas included. Works fully offline.
About AI: there's an optional AI agent (your own provider, or Ollama locally) that never changes anything without your confirmation. Also, to be upfront: most of the code was written with Claude. I designed it, reviewed it, and the server tests run against real MongoDB 6.0, 7.0, 8.0 and 8.3 servers and replica sets.
It's a new project, so I'd really appreciate feedback, especially from people running replica sets or sharded clusters in production. What would you need before trusting a tool like this with your databases?
r/mongodb • u/Horror_Farmer_2875 • 6d ago
My partial index was ignored because the query said $exists/$ne and the index said $gt "". Fixing that took it from 12s to 11ms.
Sharing because this cost me a deploy and the reason is easy to miss.
Setup: a collection with about 500k documents, 20 GB, growing 10 GB a month. One endpoint polls it all day: newest unclaimed request for a tenant. The query looked like this:
{ tenant, namespace, status: "New", "spec.curl": { $exists: true, $ne: "" } }
It had slowed to about 12 seconds.
Most documents in the collection are finished, so a normal index would mostly hold entries that never match. A partial index only indexes documents that match a condition, so I built one:
db.requests.createIndex(
{ tenant: 1, namespace: 1, status: 1 },
{ partialFilterExpression: { "spec.curl": { $gt: "" }, status: "New" } }
)
That covers a few thousand documents instead of 500k. Deployed it. Query still took 12 seconds.
`explain()` showed a COLLSCAN, so the index was not being used. The reason: MongoDB only uses a partial index when it can tell the query is a subset of the index condition. My query said `$exists: true, $ne: ""`. The index said `$gt: ""`. For string fields those match the same documents, but the planner does not reason that far. It wants the query to use a predicate it can match directly.
I changed the query to `"spec.curl": { $gt: "" }`. The index got used. 11 ms.
Second gotcha from the same week. Our app creates its indexes on startup and exits if an index with the same name exists with different options. One environment had an older version of this index (same name, partial filter was only `status: "New"`). The app crash-looped on deploy until that index was dropped. New rule for us: build the index in Atlas first with a rolling build, same name and options, wait for it to finish, then ship the code.
What I'd pass on:
- Write the query the same way as the partial filter. Same meaning is not enough.
- Run `explain("executionStats")` on the real query before you say the index is done.
- Partial indexes fit any "small active subset inside a big collection" pattern. Most queue-style collections are like that.
Does anyone have a check that catches "query does not match the partial filter" before deploy? Right now I catch it by reading the code.
r/mongodb • u/kodebineri • 6d ago
I built Rusa, an open-source MongoDB client in Flutter for Desktop & Mobile (GPLv3)
Hey everyone! After months of building, I just launched Rusa v1.0, a modern, native-feeling MongoDB client built with Flutter.Why I built it:
I wanted a lightweight alternative to heavy Electron-based MongoDB GUIs that also lets me inspect collections and run quick queries from my phone when I'm away from my desk.
What’s live in v1.0:
Supported Platforms: Windows, Linux, and Android are ready to download today (macOS and iOS are coming soon).
Open-Source (GPLv3): You can inspect the full source code and verify how credentials are stored locally.
Core Features: Fast document browsing, JSON/BSON editing, and query filtering across desktop and mobile.
Links:
Website & Downloads: https://rusa.deveditortools.com
Product Hunt Launch (would love your feedback there too!): https://www.producthunt.com/products/rusa
Let me know what OS you're testing on and what features (SSH tunneling, aggregation pipeline builder, schema analysis) would make this useful in your daily workflow!
r/mongodb • u/mr_pants99 • 8d ago
mongoexport is great for one collection. What do you use for multi-collection or non-MongoDB exports?
I work on Dsync, a database migration tool, so weigh this accordingly.
mongoexport is a great tool for pulling one collection out to JSON or CSV. Two things I've wanted from it: the same kind of export from DynamoDB or Cosmos DB, and big exports that finish faster. What the MongoDB Database Tools docs say about its limits (mongoexport, mongodump):
- mongoexport exports one collection per run (
--collectionis required) and has no parallel option. The only way the docs show to split an export is--sortwith--skipand--limit, one command per piece. The usual workaround is parallel mongoexport processes, each with a--queryon an_idrange. The request for a multi-threaded mongoexport (TOOLS-248) was closed as Won't Fix. - JSON export is relaxed Extended JSON by default. Use
--jsonFormat=canonicalif you need every BSON type back.
If the data is only in MongoDB, a shell loop running mongoexport once per collection covers several collections.
For the other cases we added an open-source File connector to Dsync. It writes Dsync sources such as MongoDB and DynamoDB to CSV, one file per collection or table, and can load the files into another Dsync destination:
dsync --mode InitialSync --namespace "shop.orders,shop.customers" \
mongodb://localhost:27017 file:///data/exportOn speed: once a collection has about 100,000 documents (twice the --doc-partition default of 50,000), Dsync splits it into _id ranges and reads them in parallel. The connector still writes its files one batch at a time, and we haven't formally benchmarked it against mongoexport.
We reworked how it handles values in v0.31.0. A key that first appears in a later document becomes a new column. ObjectIDs are written as hex, dates as ISO 8601, nested documents and arrays as Extended JSON, and on reload _id and most types come back.
Disclaimer on current limits: CSV only, no field selection. A null, a missing field and an empty string all reload as missing. A top-level string of digits, such as an order number, comes back as a number unless you pass --infer-types=false (digit strings with a leading zero stay strings), and a string holding a JSON object or array comes back as an embedded document or array. The MongoDB source refuses a collection whose smallest and largest _id have different BSON types. An export overwrites an existing file for the same collection, and there's no CDC. For backups I'd still use mongodump.
Source (Go, AGPL, PRs welcome): https://github.com/adiom-data/dsync/tree/main/connectors/file
r/mongodb • u/Alternative-Host-210 • 8d ago
When would MongoDB make a sports booking app easier to build than MySQL?
Imagine a sports booking app where every facility has a name and location, but the details vary. A swimming pool lists lane count and water depth. A badminton court lists flooring and whether it’s indoors. Facilities keep adding new amenities and sports.
If you were building this, what would be easier to add or change with MongoDB than with a MySQL design built around fixed columns?
I’m trying to explain the practical difference in one sentence without using “NoSQL” or “schema flexibility”. How would you put it? If you’d choose MySQL anyway, I’d be curious what would tip the choice for you.
r/mongodb • u/Fun-Chicken6946 • 9d ago
After months of job rejections, I spent 2 years building a MongoDB GUI. It just got added to Microsoft's Azure docs.
After struggling to land a job in 2024, when the market was pretty rough, I decided to take a different route and build something real. My goal was simple: either build something genuinely useful or gain more experience than anything else could offer.
Two years and countless 90-hour weeks later, VisuaLeaf is now featured in Microsoft's Azure DocumentDB documentation as a client for connecting to its MongoDB-compatible database service:
https://learn.microsoft.com/en-us/azure/documentdb/how-to-connect-visualeaf
It started as a MongoDB GUI, so posting this announcement really means a lot to me since this was the subreddit that started it all.
From the beginning, I wanted every part of the database workflow to feel as straightforward as possible, from exploring nested documents and building queries to database management and integrating AI. VisuaLeaf has evolved quite a bit since I first shared it here.
Today, VisuaLeaf supports MongoDB, Postgres, MySQL, SQLite, DuckDB, and 40+ more database engines.
What it does:
- Table + tree views built for nested documents: Expand nested objects and arrays directly into columns within the table instead of having to deal with json in 1 cell, or having a separate embedded view dedicated for an array. Both views stay smooth even with massive collections.
- Visual query builder + MongoDB shell: Build queries by clicking or dragging fields directly from the table and tree views, or write commands in the built-in MongoDB shell with real-time syntax error highlighting and intelligent autocomplete. Generated queries are readable and can be copied or executed.
- Data transfers with transformations: Move data between databases (Postgres → MongoDB, SQLite → MongoDB, MongoDB → MongoDB), mask sensitive fields, apply custom JavaScript transformations, and enrich data with lookups from other collections.
- Compare and sync: Compare collection structures and data, preview differences, and synchronize databases between environments, with dry-run support.
- AI / MCP: The MCP server is read-only by default. You can grant write access per connection, so an agent can run aggregations, data transfers, or anything else the app can do. There's also a built-in assistant for quick tasks, similar to Compass's.
- Sharding and clusters: manage shards on any sharded cluster (shard-key advisor, chunks, zones, balancer, resharding), or deploy and run your own self-hosted replica set or sharded cluster on Docker or Kubernetes.
- ERDs, charts, dashboards, mock data, index management, query profilers, and a lot more than I can fit into one post
- Performance: I've stress-tested datasets up to 1.6 GB, and the tree can expand thousands of rows at once. Existing grid libraries like AG-Grid couldn't support the nested column expansion I wanted, so I built my own grid from scratch, which took roughly a year to develop and optimize. (In my testing, VisuaLeaf also loaded data several seconds faster than nearly all MongoDB GUIs I’ve tested it against).
There's a free version that covers what most people need day to day:
I'd really appreciate feedback! And happy to answer any questions!
PS. VisuaLeaf is the only app that actually supports MongoDB Version 3.4 and newer versions of MongoDB in one app (from what I’ve seen).
r/mongodb • u/certain-fig-3200 • 10d ago
MongoDB Acquires Firebolt to Bring Lightning-Fast Real-Time Analytics Into Its Intelligent Data Platform
mongodb.comwhat do you guys think? Analytics play beneficial here? Are they trying to infringe on Snowflake/Databrick's turf (since I know Databricks has bought Neon, a postgres company). AI narrative?
r/mongodb • u/Round-Category-3969 • 9d ago
i m new to mongo db and have to upload this assignment now This assignment needs to be done in MongoDB using mongosh (MongoDB Shell) or MongoDB Compass
i want screenshots to upload Please 1. Q1
5 marks
Create the four collections (mentioned in Problem Statement) in MongoDB.\
For posts and comments, justify in one line each whether userId should be embedded (storing user details directly inside the document) or referenced (storing only the _id and looking it up separately), and implement the chosen design consistently across all four collections.\
Insert one sample document into each collection and display it with find() to confirm the structure before proceeding.
Drag & drop or click to browsePDF, ZIP, DOCX, PNG, JPG, DOC, TXT up to 25MB · max 1 fileQ2. Data Population
5 marks
Q2 Insert at least 6 users, 10 posts (across different users), 15 comments (across different posts) and 20 likes (across different posts/users), ensuring enough variety to support later aggregation (e.g., at least one user with multiple posts, at least one post with no comments).
Then perform: (a) find() with a filter (e.g., posts by one specific user), (b) updateOne() to edit a post's content, (c) deleteOne() to remove one comment, showing the collection state after each operation.
Drag & drop or click to browsePDF, DOCX, DOC, JPG, PNG, ZIP, TXT up to 25MB · max 1 file
Q3. Aggregation pipelines
5 marks
Write three aggregation pipelines using $match, $group and $sort: (a) total likes per post, sorted descending, (b) total posts per user, (c) average number of comments per post across the whole posts collection.
Use $lookup in at least one pipeline to join posts with users and display the user's name alongside their post's like count.
Drag & drop or click to browsePDF, ZIP, TXT, DOCX, PNG, DOC, JPG up to 25MB · max 1 file
4. Q4. Index
5 marks
Create a single-field index on posts.userId and a compound index on comments covering postId and createdAt.
Re-run one query from Q3 before and after creating the relevant index, and compare the output of explain("executionStats") (documents examined, execution time) for both runs.
Drag & drop or click to browsePDF, ZIP, TXT, DOCX, PNG, DOC, JPG up to 25MB · max 1 file
You can submit once. Make sure all files are added.
Submit
Give each image for each question seperate
r/mongodb • u/ggoggodex • 11d ago
Data migration
Hi,
We're using the Community Edition and want to migrate 20TB of data to a new cloud environment. Do you have any recommendations on the best approach, or any other advice you could share?
r/mongodb • u/rathboma • 13d 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?
r/mongodb • u/Mutitube18 • 15d ago
i need help installing mongodb on my mac
i need to download it for an assignment but everytime i try to install it this happens can any one help
r/mongodb • u/Ok-Possession-2057 • 16d ago
Giving an AI agent a throwaway copy of a MongoDB database, then reviewing what it changed
I maintain an open-source tool called Argon and wanted to share the workflow, since "how do I let an agent touch my data safely" comes up a lot.
The idea: instead of pointing an agent at the real database or an empty one, fork a sandbox from the real data. It is an ordinary MongoDB database with its own connection string and a TTL. Any driver works. Change streams record what the agent writes, so afterwards you get a diff and can merge it back or throw it away.
argon import database --uri "$MONGODB_URI" --database shop --project shop --source-quiesced
argon sandbox create -p shop --ttl 1h --watch --actor agent:run-1
# hand the printed connection string to the agent, then:
argon diff -p shop -b <sandbox>
argon merge preview -p shop -b <sandbox> # or: argon sandbox discardIn a test run the script was asked to apply a 10% discount and also deleted a product. The diff showed two updates and one delete, the source database was unchanged, and I discarded the run.
Honest limits:
- Needs a replica set (one node is fine), because it relies on change streams with pre- and post-images.
- A sandbox is a full physical copy, so creation time and storage grow with the data.
- A collection the agent creates needs changeStreamPreAndPostImages enabled before its first update, or that run's history is incomplete.
- It is not an access-control boundary. Use a restricted MongoDB user.
MIT licensed, self-hosted: https://github.com/argon-lab/argon
Longer write-up on code sandboxes vs data sandboxes: https://argonlabs.tech/blog/code-sandbox-vs-data-sandbox-for-ai-agents
Curious how others handle this today. Dump and restore per run? A staging cluster?
r/mongodb • u/VergilDev • 16d ago
Building a multi-platform gaming project (E-commerce + Community + Video) — Need stack & database feedback
Hey everyone,
I’m planning to build a multi-platform gaming project that includes:
- E-commerce store for gaming products, accessories, and merchandise
- Real-time community with posts, likes, comments, shares, images and videos
- Dedicated video section with playlists, individual video pages, and a main video feed
- Multi-language, multi-currency, and multi-payment support
- Everything working in real-time
My current preferred stack:
- Frontend: Next.js 15 + React + TypeScript + Tailwind + GSAP + Three.js
- Backend: Node.js + Express + Socket.io
- Database: MongoDB Atlas
- Cache / Real-time: Redis
- Media storage: Cloudflare R2 + CDN
Questions:
- Which database is better for a multi-platform gaming project like this — MongoDB, PostgreSQL, Cassandra, or something else?
- Is MongoDB a good primary choice for this mix of e-commerce + community + video features?
- Would you recommend adding PostgreSQL for orders and payments?
- Any better alternatives for real-time features or video handling?
- Overall architecture suggestions?
Would love honest feedback from people who have built similar multi-platform projects. Thanks!
r/mongodb • u/sh4ruu • 16d ago
MongoDB
I’m trying to aggregate collections from two different database and getsiblingdb is not working. The alternate I found if mongo script but I couldn’t export the result. Whats the real time solution
r/mongodb • u/aisatsana__ • 16d ago