Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 278442E0099 for ; Fri, 20 Jun 2008 11:25:12 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 04920-05 for ; Fri, 20 Jun 2008 11:24:49 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by developer.postgresql.org (Postfix) with ESMTP id EED9B2E008E for ; Fri, 20 Jun 2008 11:24:39 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m5KEO9ep016601; Fri, 20 Jun 2008 10:24:09 -0400 (EDT) To: Jan-Ivar Mellingen cc: Roberto Garcia , pgsql-admin@postgresql.org Subject: Re: Major upgrade advice In-reply-to: <485B57D6.4040702@alreg.no> References: <48594429.7040001@pinpointresearch.com> <48595B63.4080000@cptec.inpe.br> <485AABC9.3020807@cptec.inpe.br> <485B57D6.4040702@alreg.no> Comments: In-reply-to Jan-Ivar Mellingen message dated "Fri, 20 Jun 2008 09:10:14 +0200" Date: Fri, 20 Jun 2008 10:24:09 -0400 Message-ID: <16600.1213971849@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200806/180 X-Sequence-Number: 29518 Jan-Ivar Mellingen writes: > I got curious and did a few tests on a 8.3.3 database on my laptop. > The 3 different queries all worked, but one took twice as long. > SELECT * FROM alarmlogg WHERE alarm_tid >= CAST('2007-05-20' as > timestamp) AND alarm_tid < CAST('2008-05-21' as timestamp); > --> 301 seconds. Unsurprising: a comparison between a timestamp with timezone and one without involves a timezone conversion, so it's gonna be slow. It's a bit annoying that the system doesn't have the intelligence to convert the constants to timestamptz just once; but I think doing that would require introducing an implicit cast from timestamp to timestamptz, which might cause surprising behaviors elsewhere. regards, tom lane