
r/mongodb

Kill queries from specific AppName that runs longer than X minutes
Hello,
I have some users that are not so technical, but connect to the database regularly to extract some data.
However, sometimes they write really bad queries, or search for keys that don't exist in any document, leading to a client timeout -- however, the query continues running in the database backend for minutes. Sometimes for more than 10 minutes.
And almost everytime the users tend to insist on resubmitting the same query because the client timed out, leading to a few executions of the same query for the same amount of time..
I was thinking of a configuring some kind of kill switch for queries that run longer than X minutes, and are originated from specific appNames, for example mongoDB Compass
I am trying to avoid using maxTimeMS() as it's a global trigger, and I don't want to affect backend processes that are OK to have longer execution times, like heavy reporting and scheduled cronjobs.
paradedb/benchmarker: a workload agnostic, multi-backend benchmarking tool.
Hi r/postgresql!
We just open sourced ParadeDB Benchmarker, a multi-backend benchmarking framework built on top of the excellent Grafana k6 (blog post).
One of the goals was avoiding a shared query abstraction layer. PostgreSQL queries stay PostgreSQL queries, with their own driver and native SQL.
Supports PostgreSQL, Elasticsearch, OpenSearch, ClickHouse, MongoDB, and ParadeDB with:
- mixed read/write workloads
- support for docker-compose profiles per backend
- dataset loader
- config and setup capture
- live metrics + exported reports
One of the ah-ha moments I had building this was using the pgx Go driver in anger for the first time, I'm a Rust guy, but I'm seriously impressed with pgx and what it can do.
Any comments welcome, we will be using this to benchmark ParadeDB, but you can write your own datasets and workloads which have nothing to do with full-text search.
What are you building with AI + MongoDB?
Hi everyone! I’m a Product Manager on the Developer Experience team at MongoDB, and I’d love to learn more from this community about how you’re using MongoDB in AI applications.
A few things I’m especially curious about:
- What are you currently building with AI and MongoDB?
- What frameworks, libraries, or tools are you using? LangChain, LangGraph, LlamaIndex, Spring AI, Mastra, CrewAI, Vercel AI SDK, something else?
- Are you building agents, RAG apps, memory systems, workflow automation, eval pipelines, internal copilots, or something totally different?
- Where has MongoDB worked well for your use case?
- Where has it been harder than expected?
- What docs, integrations, examples, or product improvements would make your life easier?
I’m especially interested in hearing about real-world workflows: what you tried, what worked, what didn’t, and where you had to build around gaps.
Also, if you’ve built an open source project or example using MongoDB in an AI workflow, please share it! We’d love to see what the community is creating.
Thanks in advance. I’m here to listen and learn.
Seeking a use case for a MongoDB implementation demo (Schema design and Collections)
I need to prepare a technical presentation about MongoDB. My goal is to show why and how to choose MongoDB over a relational DB by using a practical, real-world example.
I need an example that allows me to showcase:
- Collection Structure: How to group data effectively
- Schema Design Choices
- Write Operations: Examples of interesting Inserts and Updates
- Flexibility: How the schema handles varying data fields between documents.
Thanks in advance for your help!
Hey everyone 👋
I recently created a complete MongoDB course covering beginner to advanced concepts, including Aggregation, Indexing, Atlas Search, Transactions, Sharding, Replication, and MongoDB with Node.js.
Now I’m thinking about creating more advanced MongoDB content for developers, but I want to focus on topics that are genuinely useful and don’t already have tons of resources available online.
I’d love some suggestions from the community:
- What advanced MongoDB topics do you think are underrated or poorly explained online?
- What MongoDB concepts did you struggle to learn?
- What kind of practical or real-world MongoDB content would actually help developers?
You can check the topics I’ve already covered in my documentation here:
👉 Github Notes Link
My goal is to create content that explains complex topics in a simple and practical way that’s genuinely useful for the community.
Would really appreciate your suggestions 🙌
so i was using mongodb for some project and when its time to use it it didnt connect i thought it was just bcz the server isn't running so normally i went to start the server. and got this.
➜ src git:(main) ✗ systemctl status mongod
× mongod.service - MongoDB Database Server
Loaded: loaded (/usr/lib/systemd/system/mongod.service; disabled; preset: enabled)
Active: failed (Result: exit-code) since Tue 2026-05-05 13:09:19 IST; 3s ago
Duration: 61ms
Docs: https://docs.mongodb.org/manual
Process: 188169 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=14)
Main PID: 188169 (code=exited, status=14)
CPU: 35ms
May 05 13:09:19 Ubuntu systemd[1]: Started mongod.service - MongoDB Database Server.
May 05 13:09:19 Ubuntu mongod[188169]: {"t":{"$date":"2026-05-05T13:09:19.067+05:30"},"s":"I", "c":"-", "id":8991200, "ctx":"m>
May 05 13:09:19 Ubuntu mongod[188169]: {"t":{"$date":"2026-05-05T13:09:19.069+05:30"},"s":"I", "c":"CONTROL", "id":7484500, "ctx":"m>
May 05 13:09:19 Ubuntu systemd[1]: mongod.service: Main process exited, code=exited, status=14/n/a
May 05 13:09:19 Ubuntu systemd[1]: mongod.service: Failed with result 'exit-code'.
lines 1-14/14 (END)
i am running ubuntu 24.04 lts.
Hey all,
I am joining Mongo in an outbound facing role in the coming months and my tradition when taking a new role is to sit down with an O Reilly style book, my ide and do a crash course on the technology and use cases my new role covers. Its just something I enjoy and have had success with. I was thinking of picking up Martin Fowler's NoSQL distilled but saw it was published in 2012. Not sure how it holds up. Thought I would come here and ask for any recs I should consider or to see if anyone has an opinion on the Fowler option
MongoDB Atlas connection timeout in Node.js Express despite IP whitelisting and DNS fixes
I am facing a MongoDB Atlas connection timeout issue in my Node.js + Express application.
Environment
- Node.js v24 (also tested with v22)
- Mongoose v9+ (also tested with v8.6)
- MongoDB Atlas
- VPS server (IPv4)
- Express.js backend
Problem
My application is unable to connect to MongoDB Atlas and always throws a timeout/server selection error.
Example error:
MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster
What I already tried
- IP Whitelisting
- Added my VPS public IP in MongoDB Atlas Network Access
- Also tried:
0.0.0.0/0
(still same issue)
- Different Connection Strings
Tried both:
- "mongodb+srv://"
- Standard connection string from Atlas
Still getting timeout issue.
- DNS Changes
Added public DNS servers:
- "8.8.8.8"
- "1.1.1.1"
Also tried:
require('dns').setDefaultResultOrder('ipv4first');
No change.
- Version Downgrade
Downgraded:
- Node.js 24 → 22
- Mongoose 9 → 8.6
Issue still persists.
- Network Testing
When testing connectivity from the VPS, the MongoDB domain connection also times out.
Question
What else should I check?
Could this be:
- VPS firewall issue?
- ISP/VPS provider blocking MongoDB Atlas ports?
- DNS/SRV resolution problem?
- MongoDB Atlas networking issue?
Has anyone faced a similar issue with MongoDB Atlas on a VPS?
Any debugging steps or fixes would help.
I've been building a multi-agent personal finance tracker in n8n (Telegram → main agent → sub-agents → MongoDB). The sub-agent responsible for DB retrieval is giving me wrong/hallucinated results
Architecture:
Main agent — classifies user intent, picks the correct sub-agent, passes structured instructions (intent type, user_id, date range, filters)
MongoDB sub-agent — receives that structured input, builds + runs an aggregation pipeline, returns structured JSON back to main agent
DB: MongoDB, collection: transactions
What I've already done in the sub-agent system prompt
- Full schema provided — every field, its type, allowed values, and constraints (e.g. amount_paise is the only money field, divide by 100 for INR, user_id is always an integer)
- 15 intent types defined with explicit routing rules (e.g. monthly_summary, person_cash_flow, investment_tracking, savings_rate, comparison, etc.) and clear disambiguation rules like "if a specific person's name appears → always person_cash_flow, never any other transfer intent"
- Pre-built pipeline templates for every intent — the agent isn't meant to write pipelines from scratch. Pipeline A through O are all written out. It just fills in variables like user_id, year, month
- Hard arithmetic rules — the agent is forbidden from doing any INR math itself. All division happens inside $divide:["$amount_paise",100] within the pipeline. Only 3 post-pipeline calculations are permitted (savings_rate, savings_inr, comparison delta)
- Strict $match ordering — user_id must always be the first field in every $match
- Timeframe rules — agent uses pre-computed year/month/day/week_key integer fields, never parses date strings
- Empty result handling — explicit fallback rules for every pipeline type (empty [] → return zeroed-out JSON, not an error or hallucination)
- Strict output format — output is JSON only, schema defined per intent, no markdown, no explanation
- Optional filter injection rules — how to handle amount ranges, platform normalization (always lowercase), regex for item_name/note search, etc.
Despite all this, the agent still:
- Reports transactions as non-existent when they clearly exist
- Returns wrong totals (e.g. investments total comes back as 0 when there are matching records)
- Occasionally returns a well-formatted JSON response with numbers it just made up
- Sometimes runs the right pipeline intent but with a broken $match (my suspicion)
Example(a valid case):
Main agent passes:
Find total investment transactions for May 2026, user_id, aggregation type: monthly_summary, filter: type=investment, date range: 2026-05-01 to 2026-05-31
Sub-agent returns a valid-looking monthly_summary JSON with investments: {total_inr: 6798, count: 1}
Hey mates, I want to know that one is did you write notes while preparing for this exam as writing down all definitions and examples or simply an important points or you just gone through reading all mongodb docs and practice the mock tests.
i feel happy if you share your experience and it will be helpful to others who are deciding to attempt this example.
any tips and tricks.
I have now decided that reading and practicing the mongoDB docs and one developer path with java (I am comfortable with this) and attempting mock tests.
i manage developer relations at a small company and we produce a lot of youtube content. tutorials, livestreams, conference talks, product demos. we had about 250 videos on the channel and the problem was always the same. someone on the team would need to find where we explained a specific feature or answered a specific question and there was no way to search for it besides scrolling through video titles and guessing.
i built a simple node app that stores full video transcripts in mongodb and uses text indexes to make them searchable. took an evening.
each document in the collection looks like: title, channel, publishDate, tags array, youtubeUrl, and a transcript field with the full text. i created a text index on title and transcript with weights so title matches rank higher.
for pulling transcripts i use transcript api:
npx skills add ZeroPointRepo/youtube-skills --skill youtube-full
the insert script is maybe 30 lines. call the api with the youtube url, get the transcript back, build the document, insertOne. i added a bulk mode that reads from a json file of urls for the initial backfill.
the search is a $text query with $meta textScore for sorting. an express endpoint takes a query string, runs the text search, and returns results sorted by relevance. the response includes the video title, date, score, and a truncated chunk of the transcript around the first occurrence of the search terms. frontend is a single html page with a search box.
what surprised me is how good mongodb text search is for this use case. i assumed i'd need elasticsearch for anything involving searching through long documents. but with 250 documents and a text index on the transcript field, queries come back in under 50ms. searching "authentication webhook setup" returns every video where someone explained that topic, ranked by relevance.
the team uses it constantly now. the support team searches for answers before responding to customer questions. the marketing team finds old videos to reference in blog posts. the devrel team uses it to avoid repeating content we've already covered.
about 280 videos indexed now. the collection is maybe 40mb total. running on a free atlas tier which handles our read volume without any issues. maybe 50-60 searches a day across 8 people.
the only limitation i've hit is that mongodb text search doesn't support phrase proximity. if someone searches "rate limiting configuration" it finds documents with all three words but they might be in different paragraphs. for our use case that's fine because the transcript is usually about one topic so the words are close together anyway. but if i needed more precise matching i'd probably add atlas search with lucene analyzers.
I am currently running a MongoDB setup with replication. I need to migrate around 5TB of data to a VM in my data center. To achieve this, I created a replica node on the data center VM and configured it to sync with my primary MongoDB server. The replication process starts successfully, but after transferring approximately 1.5TB of data, the main MongoDB server service stops automatically, causing the replication to fail. I have attempted this process multiple times (more than three), but the same issue occurs each time.
Has anyone faced a similar issue or can suggest a possible solution?
If you're learning backend development or preparing for interviews, MongoDB is a must-have skill.
So I created a complete MongoDB course (2026 edition) covering everything from basics to advanced topics — with real-world examples using Node.js.
🎥 Full Course (FREE on YouTube)
This is a 7+ hour deep dive where you’ll learn:
MongoDB Fundamentals
CRUD Operations
Schema Design (Embedding vs Referencing)
Indexing & Performance Optimization
Aggregation Pipeline (Beginner → Advanced)
MongoDB Atlas & Full-text Search
Transactions, Sharding & Replication
MongoDB with Node.js
📚 Complete Notes + Code (GitHub)
👉 Github
I’ve also shared:
Well-structured notes
Query examples
Aggregation pipelines
Interview-focused concepts
Perfect for revision and quick reference.
💡 Why this course?
Most tutorials either:
Skip advanced topics
Or don’t explain concepts clearly
This course is designed to:
✔ Take you from beginner → advanced
✔ Help you understand how things work internally
✔ Prepare you for real-world backend development
👨💻 Who is this for?
Beginners starting with databases
MERN stack developers
Backend developers (Node.js)
Anyone preparing for interviews
⭐ Support
If you find this helpful:
⭐ Star the GitHub repo
👍 Like & share the video
💬 Drop your feedback
🔥 Let’s connect
I’ll be posting more backend & system design content soon.
Follow for more 🚀
#mongodb #database #coding #programming #tech #backend #frontend
I’ve applied for a dev role. The feedback has been good but they take ages to come to you. Even on emails.
Is that a normal experience?
Hello everyone. I am at my wits end trying to figure this out so I apologize if I sound frustrated.
I am trying to install the PHP MongoDB extension for XAMPP. I have both Composer and Pie installed. When I try to use the Windows 11 Terminal to install the extension, I get two error messages:
- Warning: PHP Startup: Unable to load dynamic library 'mongodb' (tried: C:\xampp\php\ext\mongodb (The specified module could not be found), C:\xampp\php\ext\php_mongodb.dll (The specified module could not be found)) in Unknown on line 0
- In WindowsExtensionAssetName.php line 82: Unable to find DLL for package, checked: php_mongodb-2.3.1-8.2-ts-vs16-x86_64.dll, php_mongodb-2.3.1-8.2-vs16-ts-x86_64.dll
I have confirmed that my PHP runtime matches the file: the version is 8.2, thread safety is enabled, my CPU is 64-bit, Visual Studio is on version 1.118.1. libsasl.dll is in the /php folder. I included extension=mongodb in the php.ini file and put the path to the /php directory in the PATH. I even updated my computer, rebooted it and copied the DLL file into /System32 all to no avail. I have no idea what else to try. Any help would be greatly appreciated. Idk if it's relevant, but I am using a Lenovo ThinkPad.
I think making aggregations is boilerplate.
Are there simple atlas search query builder?