Re: [HACKERS] seq scan only when function not in subquery (bug?)

Brett McCormick <brett@work.chicken.org>

From: Brett McCormick <brett@work.chicken.org>
To: Vadim Mikheev <vadim@krs.ru>
Cc: pgsql-hackers@hub.org
Date: 1998-06-16T21:03:04Z
Lists: pgsql-hackers
On Tue, 16 June 1998, at 10:32:39, Vadim Mikheev wrote:

> Another issue - handling of functions with constant args 
> in queries - for query
> 
> select * from T where A = upper ('bbb')
> 
> function upper ('bbb') will be executed for each tuple in T!
> More of that - if there is index on T(A) then this index will
> not be used for this query!
> Obviously, upper ('bbb') should be executed (by Executor, not
> parser/planner) once: new Param type (PARAM_EXEC) implemented 
> for subselects could help here too...
> ---
> 
> Actually, this is easy to fix...

I was going to reply to this but never did -- how do you tell if it
needs to be executed once per query or once per tuple?  What if you
wanted to call a function which returned a different value for each
tuple, like random()?