I meant... I bet that it DOES evaluate the right side if the left side is
true

Justin Scott Giboney


On Fri, Dec 23, 2011 at 6:33 PM, Justin Giboney <[email protected]> wrote:

> I bet that it does not evaluate the right side if the left side is true.
> In most select statements OR means if x = 2 OR if x =3 return x. This will
> return all places where x = 2 or x = 3.
>
> I haven't had any experience with these, but you can try control flow
> functions (
> http://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html)
>
> Extended answer: MySQL does everything with sets (groupings of values) and
> it is likely that all the returned values are put into the set. One
> characteristic of sets is that they can't contain duplicates so there is no
> problem combining two sides of an OR statement. It might be possible that
> MySQL will ignore the right side if it knows that the right side and the
> left side are exactly the same (MySQL can be pretty smart about these
> things). There is also a factor that MySQL tries to optimize queries as
> much as possible and may run the right side only some of the time.
>
>
> Justin Scott Giboney
>
>
>
> On Fri, Dec 23, 2011 at 4:48 PM, Wade Preston Shearer <
> [email protected]> wrote:
>
>> Am I correct in my understanding that the right side of an OR statement
>> in an MySQL query doesn't get evaluated unless the left side fails? I have
>> a query where the left-side case of an OR occurs often and produces an
>> efficient query and the right-side happens only occasionally and produces a
>> slower, less efficient query. If the query always checks both but only uses
>> the left if it is true, then I'd be better served to move it into two
>> queries. If it only checks the right-side condition if the left-side fails
>> though, then keeping it in one makes sense.
>>
>> _______________________________________________
>>
>> UPHPU mailing list
>> [email protected]
>> http://uphpu.org/mailman/listinfo/uphpu
>> IRC: #uphpu on irc.freenode.net
>>
>
>

_______________________________________________

UPHPU mailing list
[email protected]
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net

Reply via email to