Skip to content

Add database query logging for performance monitoring #232

Description

@Aharshi3614

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
});

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions