Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 6BDB99F9AFC for ; Fri, 14 Sep 2007 08:56:48 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 78361-08 for ; Fri, 14 Sep 2007 08:56:32 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.187]) by postgresql.org (Postfix) with ESMTP id 907C99F9A93 for ; Fri, 14 Sep 2007 08:56:37 -0300 (ADT) Received: from [194.25.154.138] (helo=webserv.wug.de) by mrelayeu.kundenserver.de (node=mrelayeu7) with ESMTP (Nemesis), id 0ML2xA-1IW9mM46E3-0002KC; Fri, 14 Sep 2007 13:56:35 +0200 Received: from kretschmer by webserv.wug.de with local (Exim 3.36 #1) id 1IW9lQ-0005Bu-00 for pgsql-sql@postgresql.org; Fri, 14 Sep 2007 13:55:12 +0200 Date: Fri, 14 Sep 2007 13:55:12 +0200 From: "A. Kretschmer" To: pgsql-sql@postgresql.org Subject: Re: Optimize querry sql Message-ID: <20070914115512.GD7443@a-kretschmer.de> References: <20070914084952.GB7443@a-kretschmer.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-OS: Debian/GNU Linux - weil ich es mir Wert bin! X-Message-Flag: "Windows" is not the answer. "Windows" is the question and the answer is "no"! User-Agent: Mutt/1.5.9i X-Provags-ID: V01U2FsdGVkX1+vPLVg28EAIX7uLHYy48Wb3Us+f/b9PbQK+P3 L/FJjklpDuHb+SzSqL8gumXyogqRKAwvV845YMULsUh1i0gbeU g3a3LCQ2ZO7UESi0xs5k118oRQdmzPW X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200709/107 X-Sequence-Number: 29320 am Fri, dem 14.09.2007, um 12:26:00 +0200 mailte Stanislas de Larocque folgendes: > Hi, > > Explain my sql querry : > > Limit (cost=1057.15..1057.16 rows=1 width=27) > -> HashAggregate (cost=1057.15..1057.16 rows=1 width=27) > -> Nested Loop (cost=0.00..1057.14 rows=1 width=27) > -> Seq Scan on stat a (cost=0.00..1042.98 rows=1 width=8) > Filter: (((month)::double precision = > date_part('month'::text, (now() - '1 mon'::interval))) AND > ((year)::double precision = date_part('year'::text, (now() - '1 > mon'::interval)))) > -> Index Scan using resaller_pkey on revendeur b > (cost=0.00..14.15 rows=1 width=23) > Index Cond: ("outer".idxresaller = b.idxresaller) > Filter: (asp = 6) > > I would optimize "Seq Scan on stat a (cost=0.00..1042.98 rows=1 width=8)" > > What is your advice ? Create indexes on the columns month and year. But, again, you have an unpractical table-design. > > Thank you > > Stan > > > 2007/9/14, A. Kretschmer : Please no top-posting. (answer on top and fullquote below) Andreas -- Andreas Kretschmer Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header) GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net