Need help on indexing part in mongodb. as per developer requirement , due to poor performance, I created single key and compound indexes on certain columns of a query. But when checked I found , indexes does not getting used while query run and in Mongo Compass , there is 0 value in index execution Usage.
How can i make use of those indexes to performance improvements ?
Please also not there are two collections ( one with document which example above) which linked with DBreff - and size of both collections are 8.5 and 60.7 GB respectively. does size of collections also impacts performance ? i read on web that DBReff does impacts performance but not sure about Collection size.
This seems to be a version of the Percona fork of MongoDB server. Is this correct?
If yes, you might want to contact Percona support regarding this behaviour, since it involves modified server code that may work differently from official MongoDB servers.
What I did notice from your screenshot is, if your collections are so large, the index sizes are suspiciously small. This could be either 1) the large collections are not indexed, or 2) the Percona fork of the server is behaving differently.
does size of collections also impacts performance
In most cases, yes. If improperly indexed, larger collections would require more resources to process. For example, a query with a collection scan would then require the server to load all 8.5/60.7 GB of data from disk into memory to answer the query. This will be a massive workload if the server was provisioned with a smaller amount of RAM and slower disks.
Having said that, if your working set (data that’s frequently accessed + indexes) can comfortably fit in RAM, performance impact could be minimal even with large collections.
Thanks lot for helping out in this , can you please help to know why index usage showing 0 ? in last screenshot. How can we make them in use for queries ?
If the collection size impacts query performance what should we do about it ? do we need any old document purging scripts for this , what is the recommended size for Document and Collection in MongoDB ?
As your server is not an official MongoDB release but a fork from Percona, I’m afraid I can’t really help why those indexes are not used in this case since I have no idea what changes Percona did to the server. I would suggest contacting Percona Support for this.
Regarding collection size, query performance typically depends on:
Your provisioned hardware
Whether queries are indexed
Whether your working set fits in your provisioned RAM
How complex are your schema design
I’m afraid the answer to those questions are very use-case based and there’s no one general answer to answer them all. There is no “recommended” collection size, as a result.
Thus, this is a very deep topic with very personal answers, as what’s considered as acceptable performance to other people may not be acceptable to you, and vice versa.
However, if I may offer suggestions, I would recommend you to take a look at MongoDB University free courses, especially:
just add on - since our collection size are 60+ GB…is there any utility in mongo which can reduced the collection size ? or should we go for purging old documents from the collection? to make it reduce.