Short circuit evaluation of expressions in query

From: "Jimmy Choi" <JCHOI(at)altera(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Short circuit evaluation of expressions in query
Date: 2006-06-13 18:34:36
Message-ID: 6E3775AF29598B46AA3F102067A510F101124BED@tor-ismsg01.altera.priv.altera.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Say I have the following parameterized query in a function:

select * from foo where ($1 = -1 or foo.status = $1) and (...)

where the (...) part consists of more parameterized conditions similar
to the first one.

Suppose that at runtime, $1 is supplied a value of -1, does the
foo.status = $1 condition still have to be evaluated?

Assuming the $1 = -1 case, should the above query be as fast as the
following?

select * from foo where (...)

Thanks
Jimmy

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Qiao Yang 2006-06-13 19:13:11 MAX() across partition tables
Previous Message Luis Alberto Pérez Paz 2006-06-13 18:19:32 Re: How can I retrieve a function result?