From: | hubert depesz lubaczewski <depesz(at)depesz(dot)com> |
---|---|
To: | Stanislas de Larocque <dllstan(at)gmail(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Optimize querry sql |
Date: | 2007-09-14 13:36:41 |
Message-ID: | 20070914133641.GA31759@depesz.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Fri, Sep 14, 2007 at 03:02:59PM +0200, Stanislas de Larocque wrote:
> I want to optimize my query sql (execution time : 2665 ms) :
SELECT
b.idxreseller,
sum(a.nbrq),
b.namereseller
from
stat a,
reseller b
where
b.asp=6
and a.idxreseller=b.reseller
and a.month=date_part('month',now() - interval '1 month')
and a.year=date_part('year',now() - interval '1 month')
GROUP BY
b.idxreseller,b.namereseller limit 15;
1. cast all date_parts to int4, like in:
a.month = cast( date_part('month',now() - interval '1 month') as int4)
2. why there is a limit without any order by?
3. change it to get namereseller from subselect, not from join.
depesz
--
quicksil1er: "postgres is excellent, but like any DB it requires a
highly paid DBA. here's my CV!" :)
http://www.depesz.com/ - blog dla ciebie (i moje CV)
From | Date | Subject | |
---|---|---|---|
Next Message | Scott Marlowe | 2007-09-14 13:36:47 | Re: Optimize querry sql |
Previous Message | Stanislas de Larocque | 2007-09-14 13:02:59 | Optimize querry sql |