From: Thomas Lockhart <lockhart@alumni.caltech.edu>
To: Itai Zukerman <zukerman@math-hat.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Time Aggregates
Date: Wed, 02 Aug 2000 15:27:13 +0000
Message-ID: <39883DD1.610A0954@alumni.caltech.edu> (raw)
References: <87ittju6e7.fsf@matt.w80.math-hat.com>
> I'm currently doing this:
> SELECT symbol, date_trunc('minute', posted),
> min(price), max(price), avg(price)
> FROM trade
> GROUP BY symbol, date_trunc('minute', posted);
> to get a list of minute-averages of trade prices. I get the feeling
> that this is bad form, that I should be doing this some other way. Is
> that the case?
Looks OK to me. If you are doing this *a lot* (i.e. many more queries
than inserts), then you might want to set up another column which
contains date_trunc('minute',posted) to avoid the calculation. Something
like
create table trade (
symbol text,
posted timestamp,
price integer,
mpost timestamp
)
then define a rule to update mpost when posted gets set (haven't done
that part).
- Thomas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: lockhart@alumni.caltech.edu, zukerman@math-hat.com
Subject: Re: Time Aggregates
In-Reply-To: <39883DD1.610A0954@alumni.caltech.edu>
References: <87ittju6e7.fsf@matt.w80.math-hat.com> <39883DD1.610A0954@alumni.caltech.edu>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox