4 ms·
I think probabilistic counters are really interesting for this situation, as long as you don't need exact numbers. if random.randint(1, 100) == 1: db.i
by Squid_Tamer 2y ago
I think probabilistic counters are really interesting for this situation, as long as you don't need exact numbers.
if random.randint(1, 100) == 1:
db.increment(row)
Then, looking at the database, you can know that the actual count is approximately 100x the number of times the row was incremented.
There's an even more aggressive version that I've seen called a 'Morris Counter' which uses just a few bits to build an order-of-magnitude estimate of the number of events: https://en.wikipedia.org/wiki/Approximate_counting_algorithm https://en.wikipedia.org/wiki/Approximate_counting_algorithm