Re: Query planner: current_* vs. explicit date

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: cgg007(at)yahoo(dot)com
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Query planner: current_* vs. explicit date
Date: 2003-10-27 16:05:34
Message-ID: 29706.1067270734@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Chris Gamache <cgg007(at)yahoo(dot)com> writes:
> By giving it a definitive range I was able to coax query planner to use the
> index:

> SELECT id FROM trans_table WHERE trans_date >= (SELECT
> current_date::timestamptz) AND trans_date < (SELECT current_timestamp);

> BTW, This didn't work:

> SELECT id FROM trans_table WHERE trans_date >= current_date::timestamptz AND
> trans_date < current_timestamp;

[ scratches head... ] AFAICS the latter should "work" too. Doesn't
EXPLAIN show the same estimated row count for both versions?

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Christoph Haller 2003-10-27 16:39:36 Re: extend INSERT by 'INSERT INTO table FETCH ... FROM cursor' syntax
Previous Message sector119 2003-10-27 14:47:17 connectby