Well, if you have a very large number of queries (for example, the search engine is supposed to be), then you can simply "select" the queries. Thus, you can receive 1000 requests per second, but if you just keep the score one per second, then for a long period of time you will receive an answer that will be relatively close to the "real" answer.
Here's how, for example, the "sample" profiler works. Each n millisilin considers what function is currently being performed. Over a long period of time (a few seconds) you get an idea of the "expensive" functions, because they most often appear in your samples.
You still have to do a “count”, but by doing periodic selections, instead of counting each individual query, you can get the upper limit of the amount of data that you actually need to store (for example, a maximum of one query per second, etc.). )
source share