On Friday 06 February 2004 07:19, Octavio Alvarez wrote:
> Hi!
>
> I'd like to know if this is expected behavior. These are two couples of
> queries. In each couple, the first one has a WHERE field = function()
> condition, just like the second one, but in the form WHERE field =
> (SELECT function()). In my opinion, both should have the same execution
> plan, as the function has no parameters and, therefore, is constant.
Not necessarily constant - think about random() or timeofday().
Have you set the attributes on your function?
http://www.postgresql.org/docs/7.4/static/sql-createfunction.html
> pgdb=# explain analyze select count(*) from t_students where period =
> (select current_period_id());
It's not entirely clear to me why this form is different from the other form
though.
--
Richard Huxton
Archonet Ltd