Using LIMIT 1 in plpgsql PERFORM statements

Поиск
Список
Период
Сортировка
От Karl O. Pinc
Тема Using LIMIT 1 in plpgsql PERFORM statements
Дата
Msg-id 1129957521l.27845l.2l@mofo
обсуждение исходный текст
Ответы Re: Using LIMIT 1 in plpgsql PERFORM statements
Список 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 по дате отправления:

Предыдущее
От: Neil Conway
Дата:
Сообщение: Re: What gets cached?
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: Sequential scan on FK join