Shortcut evaluation in OR or IN

From: Tim Uckun <timuckun(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Shortcut evaluation in OR or IN
Date: 2013-05-06 02:16:38
Message-ID: CAGuHJrN7VBbCeNV0XfP8oJUH-Stdd_aBCcZ_ObECv1E0ijARdQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Say I have a select like this.

SELECT * FROM table where field = X OR field = Y limit 1

And I have two records one that matches X and one that matches Y will I
always get X because the evaluation will stop after the first clause in the
OR matches?

What about for IN (X, Y)

how about if I am doing an update

UPDATE table1 set x=table2.y where table1.field1 = table2.field1 OR
table1.field2=table2.field2

Will it update based on field1 if both fields match?

Basically I want to know if and how OR shortcuts the evaluation.

Thanks.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jasen Betts 2013-05-06 08:43:11 Re: Shortcut evaluation in OR or IN
Previous Message Yuriy Rusinov 2013-05-05 20:22:27 Re: SPI_execute_with_args call