From: | "Stanislas de Larocque" <dllstan(at)gmail(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Optimize querry sql |
Date: | 2007-09-14 08:32:45 |
Message-ID: | bc40d0a30709140132j7cf53073j9fd11ef259c06c48@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hi,
I want to optimize my qerry sql (execution time : 2448 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;
dns=> \d stat_dns_domaine;
Table «public.stat»
idxdxreseller | integer | not null
idxdo | integer | not null
idxd | integer | not null
nbrq | integer | default 0
month | integer | default date_part('month'::text, (now() -
'1 mon'::interval))
year | integer | default date_part('year'::text, (now() - '1
mon'::interval))
Index :
«stat_dns_domaine_idx_idxr_idxrevendeur» btree (idxrevendeur)
«stat_dns_domaine_idx_mois_annee_idxrev» btree (mois, annee, idxrevendeur)
\d revendeur;
Table «public.reseller»
idxreseller | integer | not null default
nextval(('idxrevendeur_seq'::text)::regclass)
namereseller | text |
asp | integer |
Index :
«reseller_pkey» PRIMARY KEY, btree (idxreseller)
Thank you
Stan
From | Date | Subject | |
---|---|---|---|
Next Message | A. Kretschmer | 2007-09-14 08:49:52 | Re: Optimize querry sql |
Previous Message | Stanislas de Larocque | 2007-09-14 08:31:39 | Optimize querry sql |