We do only display the number of visits and actions in the Real time widget so let's only request those. This should make it very fast as we can avoid the
visitors counter which is slow. Eg the visitors counter takes a few seconds on many million rows whereas the
visits counter standalone takes maybe
0.05 seconds if at all. If someone uses the API it will be still "slow" on a very large instance.
Adding a separate query for
visitors shouldn't make a huge difference as the
visitors one is so slow compared to the
In the actual "Live counter" widget we do only request the last 3 minutes were we shouldn't have any problem with the unique visitors counter as MYSQL will choose a different index automatically.
I added another tweak: If
0 we can assume that all other counters are
0 as well so we do not execute any further query at all. We can assume this as we request the
last_action_time so we should be sure there was no further action etc.
Looks good to me! :+1: