Short circuit evaluation of expressions in query - Mailing list pgsql-general

From Jimmy Choi
Subject Short circuit evaluation of expressions in query
Date
Msg-id 6E3775AF29598B46AA3F102067A510F101124BED@tor-ismsg01.altera.priv.altera.com
Whole thread Raw
Responses Re: Short circuit evaluation of expressions in query
Re: Short circuit evaluation of expressions in query
List 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

 

 

pgsql-general by date:

Previous
From: "Luis Alberto Pérez Paz"
Date:
Subject: Re: How can I retrieve a function result?
Next
From: Qiao Yang
Date:
Subject: MAX() across partition tables