Description
Currently, there's no visibility into database queries being executed. This makes it hard to identify slow queries and optimize performance.
Goals
- Log all MongoDB queries with execution time
- Identify slow queries (>100ms)
- Help optimize database performance
Implementation
mongoose.set('debug', (collectionName, method, query, doc) => {
console.log(`[DB] ${collectionName}.${method}`, JSON.stringify(query));
});
// For slow query loggin
mongoose.set('debug', {
shell: true,
// Log queries taking more than 100ms
});
Description
Currently, there's no visibility into database queries being executed. This makes it hard to identify slow queries and optimize performance.
Goals
Implementation
// For slow query loggin