Using LIMIT 1 in plpgsql PERFORM statements - Mailing list pgsql-performance

From Karl O. Pinc
Subject Using LIMIT 1 in plpgsql PERFORM statements
Date
Msg-id 1129957521l.27845l.2l@mofo
Whole thread Raw
Responses Re: Using LIMIT 1 in plpgsql PERFORM statements
List pgsql-performance
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


pgsql-performance by date:

Previous
From: Neil Conway
Date:
Subject: Re: What gets cached?
Next
From: Alvaro Herrera
Date:
Subject: Re: Sequential scan on FK join