Skip site navigation (1) Skip section navigation (2)

SQL Question: Averages of intervals.

From: "Daniel Staal" <DStaal(at)usa(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: SQL Question: Averages of intervals.
Date: 2009-01-23 20:39:42
Message-ID: 14759.152.121.16.49.1232743182.squirrel@www.magehandbook.com (view raw or flat)
Thread:
Lists: pgsql-novice
I have the following table:

LoadTable:
 MachineName - String
 Date        - Date
 Time        - Time
 IOW         - Real
 SYS         - Real
 USR         - Real
 ...         - Real

I am trying to get information out for using in a graph.  Unfortunately,
we are logging several times a minute, so the amounts of data for any
reasonable timeframe (say, one day) are just too large for any one graph
to handle well.

So, what I'd like to do is average the IOW (or whichever I'm graphing at
the moment) over a timeframe.  (Where I would probably scale the timeframe
depending on the total length of time I'm pulling.)  So, the result would
contain one row per interval, with the IOW/whatever being the average
value over the interval.

Is there any way to do this in straight SQL?  (Let's use one day (Date =
'$date') and 10 minutes as examples: I'll probably be creating an
interface to generate these ad-hock, over random timeframes.)

Daniel T. Staal


Responses

pgsql-novice by date

Next:From: Nico CallewaertDate: 2009-01-24 00:43:01
Subject: Function call
Previous:From: Michael SwierczekDate: 2009-01-22 18:01:42
Subject: Re: Newbie question PostgreSQL / Postgres Plus / Tuning

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group