X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 972BD9FB0D1 for ; Tue, 30 May 2006 18:52:29 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 22162-03 for ; Tue, 30 May 2006 18:52:17 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mx2.ipf.is (scania.ipf.is [85.197.192.147]) by postgresql.org (Postfix) with ESMTP id 2C9C09FA5E9 for ; Tue, 30 May 2006 18:52:15 -0300 (ADT) Received: (qmail 25647 invoked by uid 1010); 30 May 2006 21:50:25 +0000 Received: from 85.197.216.186 by scania (envelope-from , uid 1008) with qmail-scanner-1.25-st-qms (clamdscan: 0.88/1235. spamassassin: 3.1.1. perlscan: 1.25-st-qms. Clear:RC:1(85.197.216.186):SA:0(-4.2/4.5):. Processed in 0.66575 secs); 30 May 2006 21:50:25 -0000 X-Antivirus-IPF-Mail-From: gnari@hive.is via scania X-Antivirus-IPF: 1.25-st-qms (Clear:RC:1(85.197.216.186):SA:0(-4.2/4.5):. Processed in 0.66575 secs Process 25635) Received: from dsl-216-186.hive.is (HELO ?192.168.1.34?) (85.197.216.186) by mx2.ipf.is with SMTP; 30 May 2006 21:50:24 +0000 Subject: Re: Split select completes, single select doesn't and From: Ragnar To: Anthony Ransley Cc: pgsql-performance@postgresql.org In-Reply-To: <447B9143.6010407@aurema.com> References: <447B9143.6010407@aurema.com> Content-Type: text/plain; charset=ISO-8859-1 Date: Tue, 30 May 2006 21:53:20 +0000 Message-Id: <1149026000.8566.119.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/551 X-Sequence-Number: 19338 On ūri, 2006-05-30 at 10:26 +1000, Anthony Ransley wrote: > Can any one explain why the following query > > select f(q) from > ( > select * from times > where '2006-03-01 00:00:00'<=q and q<'2006-03-08 00:00:00' > order by q > ) v; > > never completes, but splitting up the time span into single days does work. > > select f(q) from > ( > select * from times > where '2006-03-01 00:00:00'<=q and q<'2006-03-02 00:00:00' > order by q > ) v; first question: is f() relevant to your problem? I mean do you see the same effect with: select q from ( select * from times where '2006-03-01 00:00:00'<=q and q<'2006-03-08 00:00:00' order by q ) v; or even: select q from times where '2006-03-01 00:00:00'<=q and q<'2006-03-08 00:00:00' order by q if f() is needed to make this happen show us f() if f() is not relevant, show us the simplest cases where you see this. show us EXPLAIN on the query that does not finish, show us EXPLAIN ANALYZE on the queries that do. second question: what indexes exist on the table "times" ? another question: how many rows in the table ? next question: is the table newly ANALYZED? finally: what version of postgresql are you using? whithout more info , it is difficult to guess what your problem is, but possibly you need to increase the statistics target of column "q" gnari