From: Richard Huxton <dev@archonet.com>
To: alvarezp@alvarezp.ods.org
To: pgsql-performance@postgresql.org
Subject: Re: Seq scan on zero-parameters function
Date: Fri, 6 Feb 2004 08:50:50 +0000
Message-ID: <200402060850.50818.dev@archonet.com> (raw)
In-Reply-To: <4207.192.168.0.64.1076051944.squirrel@alvarezp.ods.org>
References: <4207.192.168.0.64.1076051944.squirrel@alvarezp.ods.org>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: dev@archonet.com, alvarezp@alvarezp.ods.org, pgsql-performance@postgresql.org
Subject: Re: Seq scan on zero-parameters function
In-Reply-To: <200402060850.50818.dev@archonet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox