Brian Hirt <[EMAIL PROTECTED]> writes: > it's more like: > declare > foo_date date; > begin > select some_date into foo_date from some_table where something = > something_else; > select blah from redir_log where redir_timestamp >= foo_date::timestamp > without time zone at time zone 'GMT'; > etc / etc / etc
Ah. In that case you're going to have trouble anyway with the planner having no clue what the effective value of the comparison expression is, because it'll certainly not be able to fold the plpgsql variable to a constant. I agree with the other person who suggested faking it out by adding a dummy other-side-of-the-range constraint, perhaps AND redir_timestamp <= now() (or whatever upper bound is okay for your purposes). This should coax it into using an indexscan. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly