Re: optimyzing - Mailing list pgsql-sql

From Masaru Sugawara
Subject Re: optimyzing
Date
Msg-id 20020403003510.CEE3.RK73@sea.plala.or.jp
Whole thread Raw
In response to optimyzing  (Mathieu Arnold <mat@mat.cc>)
List pgsql-sql
On Mon, 01 Apr 2002 19:14:57 +0200
Mathieu Arnold <mat@mat.cc> wrote:

> and I can't get a query to have the average of that without having to do
> this subselect.
> 
>       avg
> ----------------
>  886.6585292820
> 


It seems to me that the query can be rewritten without a sub-query,
even though the number of sampling per day is not always kept 
at a constant value.

  SELECT SUM(traffic)::float / COUNT(DISTINCT date(time))::float                       / 1024.0 / 86400.0 AS avg
FROM  stats  WHERE  ip = '212.43.217.66' AND date(time) < date('now')
 


Regards,
Masaru Sugawara




pgsql-sql by date:

Previous
From: Keith Gray
Date:
Subject: Database Locations
Next
From: george young
Date:
Subject: vacuum full fails: Parent tuple was not found[7.2]