Re: Problem with index in OR'd expression - Mailing list pgsql-general

From postgresql.org@tgice.com
Subject Re: Problem with index in OR'd expression
Date
Msg-id 45919044.3040008@tgice.com
Whole thread Raw
In response to Re: Problem with index in OR'd expression  (postgresql.org@tgice.com)
Responses Re: Problem with index in OR'd expression
List pgsql-general
postgresql.org@tgice.com wrote:
> Tom Lane wrote:
>> you're still gonna lose because those are variables not constants ...
>
> Well, that *is* what I'm hoping to do.  I understand how (0 IS NULL) is
> different from (variable IS NULL), but isn't it reasonable to expect
> that PG could evaluate that expression only once (knowing that the
> variable couldn't change during the course of the query execution) and
> then treat that expression as constant?

Also, I should mention that in my case, the "variables" are actually
constants either defined in the function param list (and thus
non-modifiable within the function body) or defined with:

   DECLARE vC1 CONSTANT varchar(10) := 'blah'

-type syntax.  I would submit that in that situation, it would be
reasonable for a user to expect my suggested syntax to still use the
indicated indexes.

Do you agree?  It it possible that something other than picking up the
'IS NULL' boolean as constant has changed between 8.0.x & 8.2 that might
make this work?

Thanks,

jl

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Optimization of unnecessary GROUP BY columns
Next
From: Tom Lane
Date:
Subject: Re: Problem with index in OR'd expression