M
M
Maxim2014-06-07 00:58:28
PHP
Maxim, 2014-06-07 00:58:28

How to create an algorithm for collecting and displaying game server statistics?

I write game server monitoring. Every minute I get information about servers. Interested in issuing information to the user. It is necessary to build graphs for the month, for the day and for the hour. What is the best way to do all this?
Now for the day and hour I choose this:

SELECT * FROM `tbl` WHERE `date` > NOW() - INTERVAL 1 DAY GROUP BY DATE_FORMAT(`date`,'%y%j%H');

SELECT * FROM `tbl` WHERE `date` > NOW() - INTERVAL 1 HOUR GROUP BY DATE_FORMAT(`date`,'%y%j%H%i');

this option was spied here -> MySQL Select of each n-th row
This option is not suitable for the month, since the values ​​​​are taken at 00:00, and this is not very good for the statistics of the game server. I’m scrolling through the idea in my head to take the average values ​​for the day and show them to the user, but I don’t know how to implement it correctly, because I think that choosing all the values ​​for the month and calculating the average will be quite stressful.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel K, 2014-06-07
@PavelK

Can be separate tables - in one on hours.
In another, after a day (by krone, for example), make a record - calculations of the average daily
. In another, similarly for months.
Statistics do not change retroactively, so it will not need to be recalculated every time.
You can only choose from the corresponding tables, if necessary, and group them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question