Does psql evaluate OR conditions in order?

Поиск
Список
Период
Сортировка
Искать
От
HideMe
Тема
Does psql evaluate OR conditions in order?
Дата
Msg-id
e364b7b91b2f303cb37add13b25b799a@webmail.webfaction.com
Список
Дерево обсуждения
Does psql evaluate OR conditions in order? HideMe <r36@tara-lu.com>
Re: Does psql evaluate OR conditions in order? Tom Lane <tgl@sss.pgh.pa.us>
Re: Does psql evaluate OR conditions in order? Gavan Schneider <pg-gts@snkmail.com>
Re: Does psql evaluate OR conditions in order? Roxanne Reid-Bennett <rox@tara-lu.com>
Postgres 9.1
Ubuntu something.

We have a stored procedure that performs the following evaluations:

IF ST_Intersects(line1, line2) OR ST_Intersects(line3, line4) THEN
    do stuff
ELSIF ST_Intersects(line5, line6) OR ST_Intersects(line7, line8) THEN
    do stuffB
END IF;

98% of the time the 2nd half of these IF statements will never be true.
ST_Intersects is an expensive operations to perform.

Given we're executing this across a lot of data... avoiding expensive 
calls is a good idea.
So, can we count on the evaluation of the 1st half of the IF's being 
done first before trying the 2nd half, or
should we re-write the IF/ELSE to

IF ST_Intersects(line1, line2) THEN
    do stuff
ELSIF ST_Intersects(line5, line6) THEN
    do stuffB
ELSIF ST_Intersects(line3, line4) THEN
    do stuff
ELSIF ST_Intersects(line7, line8) THEN
    do stuffB
END IF;


Roxanne

В списке pgsql-novice по дате отправления
От: jody
Дата:
Сообщение: Re: db dump from php
От: Tom Lane
Дата:
FAQ