Why are requests inside the system.profile collection rewritten

I am trying to collect all my requests occurring on mongodb regarding my Applciation. So, I set the profiling level to 2 so that it logs all requests. As part of the architecture, as soon as the user logs in, abusive updates occurring on mongodb will appear.

But I noticed that the number of system.profile decreasing, I don’t know why

 > db.system.profile.count() 322 > db.system.profile.count() 351 > db.system.profile.count() 202 > db.system.profile.count() 136 > db.system.profile.count() 233 

Why in my case are requests rewritten?

Is there a possibility that I can record all my differences requests occurring for my application.

I need this because I can remove / add some of the indexes to one of my collections.

+7
mongodb
source share
2 answers

system.profile is a limited collection with a default size of 1 MB, so documents are cleaned naturally (with respect to the timestamp) to make room for new documents.

To increase the size of the system.profile collection (say, 10 MB), follow these steps:

1) Stop profiler: db.setProfilingLevel(0)

2) Drop system.profile: db.system.profile.drop()

3) Create a larger collection of system.profile manually: db.createCollection( "system.profile", { capped: true, size: 1024 * 1024 * 10 } )

4) Enable profiling again

If on average a collection of 1 MB collected about 200-300 documents, the new settings will be about 2000-3000 documents. Increase the size of the system.profile file as needed.

+20
source share

Here's a link to the official documentation https://docs.mongodb.org/manual/tutorial/manage-the-database-profiler/#profiler-overhead

You need to make a change to the collection size of the collection system.profile

+1
source share

All Articles