MySQL Forums
Forum List  »  General

Re: precedence of operators
Posted by: Jean Beaulieu
Date: July 08, 2014 10:09AM

Rick James Wrote:
-------------------------------------------------------

> Let's see the indexes (SHOW CREATE TABLE) and the
> real WHERE clause. Also, do EXPLAIN SELECT ...;
> that will show whether it will use any of the
> indexes.
>
> If you have a million rows, I'll show you a way to
> make the geolocation code run _much_ faster.
> If you have a thousand rows, I'll bet you can't
> see any significant difference when benchmarking
> your two choices of ordering ANDs.

Thanks a lot for the answer! I may have 100,000 rows after a year, not a million, but 300,000 could be possible in the long run.
The where clause is not static, it varies, depending of the user input. The geolocation clause however will be a test within a range (longitude and latitude), fortunately there is a field province/state (within a country) that I can add in the AND clause, I have the feeling that it will make it much faster than an arithmetic operation.
An example of an sql statement that was generated by my php code (and executed):

SELECT * FROM `robot1` where type=1 AND `choix_port_robot`=27 AND (`bout_nez`=1 OR `bout_nez`=-1 ) AND `oeil_au_beur_noir`=0 AND (( `pelage`=3 AND ( (`couleur1`=3 AND `couleur2`=4) OR ( `couleur2`=3 AND `couleur1`=4)) ) OR (`pelage`=2 AND ((`couleur1`=3 AND (`couleur2`=4 OR `couleur2`=5) ) OR ( `couleur2`=3 AND (`couleur1`=4 OR `couleur1`=5) ))) ) AND (`pelage`=2 OR `pelage`=3) AND ( `latitude` > 45.2162875455 AND `latitude` < 46.1253784545 AND `longitude` > -74.166362 AND `longitude` < -72.916362) AND (`masque_tabby`=-1 OR `masque_tabby`=0)

Options: ReplyQuote


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


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.