I have a table with lots of system performance data, with the following columns: IID: unique id TIMESTAMPT ITIME: date/time when the data was collected VARCHAR(16) ITYPE: type of data INTEGER IVAL: data value
The class looks like: class PerfData{ Date time; String type; int val; } When ITYPE="CPU", it means performance data of CPU.
Now I want to show average CPU usage in every minutes in the past 24 hours. It's easy to limit time to the last 24 hours. Problem is I need to do an aggregation on val, which will be avg(val). But what shall I do for the GROUP BY part? How can I define a group by to group data of the same minute from HQL?
I will run the app on Oracle. If there's a general HQL way which can keep DB-independence, it will be great! But if it is too difficult, I won't mind to use Oracle-specific solution for now.
And the aggregation period is flexible, it can be 1 minute, 5 minutes, half hour, 1 hour, half day, 1 day, 1 week, 1 month, etc.
If you have done anything similar before, it will be greatly appreciated if you can share your experience.
Thanks!
Li
|