Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 13E2D475B8E for ; Thu, 30 Jan 2003 10:54:12 -0500 (EST) Received: from termit.gingerall.cz (termit.gingerall.cz [212.24.153.2]) by postgresql.org (Postfix) with ESMTP id EBBAC475A7F for ; Thu, 30 Jan 2003 10:54:10 -0500 (EST) Received: from gingerall.cz (IDENT:Rp1MsxYGnVYearpP8VMJXDTyVh/IUgRT@angrest.gingerall.cz [212.24.153.10]) by termit.gingerall.cz (8.11.2/8.11.6) with ESMTP id h0UFsEA14818 for ; Thu, 30 Jan 2003 16:54:14 +0100 Message-ID: <3E394AA6.8080400@gingerall.cz> Date: Thu, 30 Jan 2003 16:54:14 +0100 From: Pavel Hlavnicka User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2) Gecko/20021203 X-Accept-Language: en, cs MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: calculated expressions and index use Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/506 X-Sequence-Number: 11371 Hi all, I use simple sql statement like this select * from foo where created_at >= 'now'::timestamp - '1 hour'::interval; My table is indexed on created_at field. The query above doesn't use it, but if I use select * from foo where created_at >= 'now' the index is used. It looks like if the engine finds some expression to be evaluated it gets rid of any index use (due the possible dependency?). Is it possible to do something to 'precompute' some value in the query condition, so planner understand is as a constant value? (... and I've got some reason NOT to use a parameter in my Perl DBI code...) Maybe my conclusions are wrong, of course. Thank you very much in advance Pavel -- Pavel Hlavnicka Ginger Alliance www.gingerall.com