From: Karl O. Pinc <kop@meme.com>
To: pgsql-performance@postgresql.org
Subject: Using LIMIT 1 in plpgsql PERFORM statements
Date: Sat, 22 Oct 2005 05:05:21 +0000
Message-ID: <1129957521l.27845l.2l@mofo> (raw)
Hi,
I'm wondering if the plpgsql code:
PERFORM 1 FROM foo;
IF FOUND THEN ...
is any slower than:
PERFORM 1 FROM foo LIMIT 1;
IF FOUND THEN ...
Seems like it _could_ be smart enough to know that
1) It's selecting from a real table and not a function
2) GET DIAGNOSTICS is not used
and therefore it does not have to do more than set
FOUND, and need find only one row/plan the query
to find only one row. I'm particularly interested
in the query plan optimization aspect.
Would it be considered poor practice to rely on
such an optimization?
Thanks.
Karl <kop@meme.com>
Free Software: "You don't pay back, you pay forward."
-- Robert A. Heinlein
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-performance@postgresql.org
Cc: kop@meme.com
Subject: Re: Using LIMIT 1 in plpgsql PERFORM statements
In-Reply-To: <1129957521l.27845l.2l@mofo>
* 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