Received: from news.tht.net (news.hub.org [216.126.91.242]) by postgresql.org (8.11.3/8.11.4) with ESMTP id fA90bOm26843 for ; Thu, 8 Nov 2001 19:37:24 -0500 (EST) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.4/8.11.4) id fA90NVS53928 for pgsql-sql@postgresql.org; Thu, 8 Nov 2001 19:23:31 -0500 (EST) (envelope-from news) From: "fstelpstra@yahoo.com" X-Newsgroups: comp.databases.postgresql.sql Subject: Re: Can this query be optimized? Date: Fri, 9 Nov 2001 01:26:32 +0100 Organization: XS4ALL Internet BV Lines: 26 Message-ID: <9sf7m2$if1$1@news1.xs4all.nl> References: <16760.1005229805@sss.pgh.pa.us> Reply-To: fstelpstra@yahoo.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Complaints-To: abuse@xs4all.nl User-Agent: KNode/0.4 To: pgsql-sql@postgresql.org X-Archive-Number: 200111/140 X-Sequence-Number: 5524 Hi, Isn't it much faster if you extract a substring from the date field? For example if the date field returns 2001/12/30, you could use the 4th and 5th position for the month part. regards, freek Tom Lane wrote: > Claus Heiko Niesen writes: >> I'm stuck optimizing the following query: >> select distinct extract(year from date) as year, extract(month from date) >> as month, date from week_pics order by date desc; > > Perhaps it would work to forget the "distinct" and instead GROUP BY > date. > > regards, tom lane > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) >