From: db@zigo.dhs.org
To: Gregory S. Williamson <gsw@globexplorer.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Horribly slow query/ sequential scan
Date: Tue, 9 Jan 2007 13:35:36 +0100 (CET)
Message-ID: <37813.192.121.104.48.1168346136.squirrel@zigo.dhs.org> (raw)
In-Reply-To: <71E37EF6B7DCC1499CEA0316A256832802B3EB8A@loki.wc.globexplorer.net>
References: <71E37EF6B7DCC1499CEA0316A256832802B3EB8A@loki.wc.globexplorer.net>
I don't think I understand the idea behind this query. Do you really need
billing_reports twice?
> The query:
> explain analyze select
> w.appid,w.rate,w.is_subscribed,sum(w.hits) AS Hits ,sum(w.sius) AS IUs,
> sum(w.total_amnt) AS Total,sum(w.hits) * w.rate AS ByHits,
> sum(w.sius) * w.rate AS BYIUS
> from bill_rpt_work w, billing_reports b
> where w.report_id in
> (select b.report_id from billing_reports where b.report_s_date =
> '2006-09-30')
> and (w.client_id = '227400001' or w.client_id = '2274000010')
> group by 1,2,3
> order by 1,2,3;
Maybe this is the query you want instead?
select w.appid,
w.rate,
w.is_subscribed,
sum(w.hits) AS Hits,
sum(w.sius) AS IUs,
sum(w.total_amnt) AS Total,
sum(w.hits) * w.rate AS ByHits,
sum(w.sius) * w.rate AS BYIUS
from bill_rpt_work w
where w.report_id in
(select b.report_id from billing_reports b where b.report_s_date =
'2006-09-30')
and (w.client_id = '227400001' or w.client_id = '2274000010')
group by 1,2,3
order by 1,2,3;
/Dennis
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 using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: db@zigo.dhs.org, gsw@globexplorer.com
Subject: Re: Horribly slow query/ sequential scan
In-Reply-To: <37813.192.121.104.48.1168346136.squirrel@zigo.dhs.org>
* 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