Re: Precedence in WHERE clauses.

2014-03-25 Thread shawn l.green
Hello Christophe, On 3/23/2014 2:34 PM, Christophe wrote: Hi all, Le 20/03/2014 13:20, Christophe a écrit : Hi Morgan, Harald, and all, Thanks for the answers. While reading your answers, I realize one more time this problem does not seem so obvious ... That's why I asked ;) . Beyond the sp

Re: Precedence in WHERE clauses.

2014-03-23 Thread Christophe
Hi all, Le 20/03/2014 13:20, Christophe a écrit : > Hi Morgan, Harald, and all, > > Thanks for the answers. > > While reading your answers, I realize one more time this problem does > not seem so obvious ... That's why I asked ;) . > > Beyond the specific case I mentioned, my goal is also to ge

Re: Precedence in WHERE clauses.

2014-03-20 Thread Roy Lyseng
Hi Christophe, On 20.03.14 13:18, Christophe wrote: Hi Michael, Le 18/03/2014 20:28, Michael Dykman a écrit : Also, as you currently have it, the expression DATE_SUB(NOW(), INTERVAL 24 is going to be executed once for every single candidate row. I would suggest you temporarily memoize that l

Re: Precedence in WHERE clauses.

2014-03-20 Thread Christophe
Hi Morgan, Harald, and all, Thanks for the answers. While reading your answers, I realize one more time this problem does not seem so obvious ... That's why I asked ;) . Beyond the specific case I mentioned, my goal is also to get a general discussion about theorical behaviour of MySQL while han

Re: Precedence in WHERE clauses.

2014-03-20 Thread Christophe
Hi Michael, Le 18/03/2014 20:28, Michael Dykman a écrit : > > Also, as you currently have it, the expression DATE_SUB(NOW(), > INTERVAL 24 is going to be executed once for every single candidate > row. I would suggest you temporarily memoize that like so: > > select into DATE_SUB(NOW(), INTERVA

Re: Precedence in WHERE clauses.

2014-03-19 Thread shawn l.green
On 3/19/2014 7:27 PM, Mogens Melander wrote: G'morning A function in a where equals what ? On Wed, March 19, 2014 15:05, Morgan Tocker wrote: Hi Christophe, Considering the following simple query : SELECT * FROM Status WHERE DWProcessed = 0 AND PreviousStatus NOT IN ('PENDING', 'ACCEPTED'

Re: Precedence in WHERE clauses.

2014-03-19 Thread Mogens Melander
G'morning A function in a where equals what ? On Wed, March 19, 2014 15:05, Morgan Tocker wrote: > Hi Christophe, > >> Considering the following simple query : >> >> SELECT * FROM Status WHERE DWProcessed = 0 AND PreviousStatus NOT IN >> ('PENDING', 'ACCEPTED') AND SubscribeDate < DATE_SUB(NOW(),

Re: Precedence in WHERE clauses.

2014-03-19 Thread Reindl Harald
Am 19.03.2014 16:27, schrieb Morgan Tocker: > Reindl, you can call me Harald >>> The order of the WHERE clause does not matter >> >> that is simply not true >> >> otherwise that documentation would not exist >> http://dev.mysql.com/doc/refman/5.5/en/multiple-column-indexes.html > > Yes, the ord

Re: Precedence in WHERE clauses.

2014-03-19 Thread Morgan Tocker
Reindl, >> The order of the WHERE clause does not matter > > that is simply not true > > otherwise that documentation would not exist > http://dev.mysql.com/doc/refman/5.5/en/multiple-column-indexes.html Yes, the order of the columns in composite indexes *does matter*. This is a different que

Re: Precedence in WHERE clauses.

2014-03-19 Thread Reindl Harald
Am 19.03.2014 15:05, schrieb Morgan Tocker: > When a MySQL server receives a query, it goes through a process called query > optimization > and tries to determine the best way to execute it (based on availability of > indexes etc) > > The order of the WHERE clause does not matter that is simpl

Re: Precedence in WHERE clauses.

2014-03-19 Thread Morgan Tocker
Hi Christophe, > Considering the following simple query : > > SELECT * FROM Status WHERE DWProcessed = 0 AND PreviousStatus NOT IN > ('PENDING', 'ACCEPTED') AND SubscribeDate < DATE_SUB(NOW(), INTERVAL 24 > HOUR); > > Which of these filters are processed first ? > > I'd like the first filter (D

Re: Precedence in WHERE clauses.

2014-03-19 Thread Glyn Astill
> From: Christophe > To: mysql@lists.mysql.com > Cc: > Sent: Tuesday, 18 March 2014, 19:10 > Subject: Precedence in WHERE clauses. > > Hi list, > > I'd like to get your advice about precedence in where clauses in MySQL > (5.0.51, and 5.1.66 in this case / from lenny and squeeze Debian > packa

Re: Precedence in WHERE clauses.

2014-03-18 Thread Michael Dykman
My advice to you is to make use of the EXPLAIN facility which porovides the most accurate information about how MySQL is going to treat your query. Also, as you currently have it, the expression DATE_SUB(NOW(), INTERVAL 24 is going to be executed once for every single candidate row. I would sugge