Re: *very* slow query to summarize data for a month ...

From: Dennis Bjorklund <db(at)zigo(dot)dhs(dot)org>
To: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: *very* slow query to summarize data for a month ...
Date: 2003-11-11 06:50:07
Message-ID: Pine.LNX.4.44.0311110747090.26313-100000@zigo.dhs.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Mon, 10 Nov 2003, Marc G. Fournier wrote:

>
> explain analyze SELECT ts.company_id, company_name, SUM(ts.bytes) AS total_traffic
> FROM company c, traffic_logs ts
> WHERE c.company_id = ts.company_id
> AND month_trunc(ts.runtime) = '2003-10-01'
> GROUP BY company_name,ts.company_id;

What if you do

ts.runtime >= '2003-10-01' AND ts.runtime < '2003-11-01'

and add an index like (runtime, company_name, company_id)?

--
/Dennis

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Greg Stark 2003-11-11 17:47:06 Re: *very* slow query to summarize data for a month ...
Previous Message Marc G. Fournier 2003-11-11 00:49:57 Re: *very* slow query to summarize data for a month ...