MySQL Forums
Forum List  »  General

precedence of operators
Posted by: Jean Beaulieu
Date: July 07, 2014 12:15PM

Hi,
My database (mysql) will be quite large at some point, so I must know before which pattern in preferable. The pattern that I have right now is
SELECT * FROM TABLE WHERE (A) AND (B OR C BLABLABLA)
but I'm unsure if it's not better to use
SELECT * FROM TABLE WHERE (B OR C BLABLABLA) AND (A)

The second parenthesis (B OR C BLABLABLA) contains many statements combined with AND, OR, <>, =, etc...t's too long to give them all
The first parenthesis contains 'A', which is in reality a test inside a gap of longitudes and latitudes ( like if (table.long > longit_min AND table.long < longit_max AND table.lat < latit_max AND table.lat > latit_min)

The geolocation test would eliminate 99.8% of the records, but the bigger parenthesis at most 80% of the records, so obviously I prefer to eliminate 99.8% and after eliminate 80% of what's left.
How can I do this if I want the instructions over longitude/latitude executed first?
Is my reasonnig correct?

Options: ReplyQuote


Subject
Written By
Posted
precedence of operators
July 07, 2014 12:15PM
July 08, 2014 08:38AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.