averaging data with Activerecord

I have a database table of timestamped scalars with each row (scalar)
added every 15 seconds. I want to process a day's worth of data so
that an average scalar of every 30 minutes is returned. I would like
to return the averaged data in an array. What is the most effecient
way to do this with performance in mind? Could the 'group' option in
the 'average' method for a model be used?

Thanks,
Chirag

What's a scalar in this context ? Did I miss something ?

If you're looking for raw performance, write a stored procedure.

I have a database table of timestamped scalars with each row
(scalar) added every 15 seconds. I want to process a day's
worth of data so that an average scalar of every 30 minutes
is returned. I would like to return the averaged data in an
array. What is the most effecient way to do this with
performance in mind? Could the 'group' option in the
'average' method for a model be used?

ActiveRecord doesn't really have much to offer you in this regard, this
is largely a pure SQL question. What you need to do is add a column to
the resultset with the time rounded to the nearest half an hour - either
by decorating the data with a view or, probably more efficiently, doing
it on insert. Given that, you can easily average and group the data
either in raw SQL or using ActiveRecord's aggregation methods. The
latter might look like:

Timestamps.average(:scalar, :group=>'half_hour')

- donald