Received: from localhost (unknown [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 3CDAB9F99BF for ; Fri, 14 Sep 2007 05:32:55 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 93153-06 for ; Fri, 14 Sep 2007 05:32:49 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.239]) by postgresql.org (Postfix) with ESMTP id 369569F99E5 for ; Fri, 14 Sep 2007 05:32:52 -0300 (ADT) Received: by wx-out-0506.google.com with SMTP id r21so744584wxc for ; Fri, 14 Sep 2007 01:32:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=4/MqYXvNxYP6Bx6yuh1pWXXH8Au6+Zzzg8eNvlFfEm0=; b=o6ThorQdO7xfAxi74w9WrRZ89SOR608BDOEyZMikLyCOZ4yV23v3l4vXKq5hkvZgHvuZiPqPwEvC96IMnzUz4NXuxT9xelxWx2marHY0PuFOLp0eBADyQc2OKFeQDaAMahED0RBcTrEYt4SPmyJd8SrZJJC6xng9Wp1IYdaWca4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=CCmBbk7wm3kV4LRLrrB9rL5dOu9saWClkCzfaoP3BeVnZhLEhSoeE+dRU/2Ai4MQcp0SsVNp7/cSWLiS727H7URHkm/HSX/JpxWEHHD4gc3Bh3NQDxnm8I4Z6dgkF7J+sd3NKe/qbx4igw9P7+eK+EVohW634fMXzI3Y5WtUx10= Received: by 10.90.104.14 with SMTP id b14mr29025agc.1189758765907; Fri, 14 Sep 2007 01:32:45 -0700 (PDT) Received: by 10.90.70.5 with HTTP; Fri, 14 Sep 2007 01:32:45 -0700 (PDT) Message-ID: Date: Fri, 14 Sep 2007 10:32:45 +0200 From: "Stanislas de Larocque" To: pgsql-sql@postgresql.org Subject: Optimize querry sql MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200709/104 X-Sequence-Number: 29317 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=3D6 and a.idxreseller=3Db.reseller and a.month=3Ddate_part('month',now() - interval '1 month') and a.year=3Ddate_part('year',now() - interval '1 month') GROUP BY b.idxreseller,b.namereseller limit 15; dns=3D> \d stat_dns_domaine; Table =ABpublic.stat=BB 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 : =ABstat_dns_domaine_idx_idxr_idxrevendeur=BB btree (idxrevendeur) =ABstat_dns_domaine_idx_mois_annee_idxrev=BB btree (mois, annee, idxrev= endeur) \d revendeur; Table =ABpublic.reseller=BB idxreseller | integer | not null default nextval(('idxrevendeur_seq'::text)::regclass) namereseller | text | asp | integer | Index : =ABreseller_pkey=BB PRIMARY KEY, btree (idxreseller) Thank you Stan