MySQL Forums
Forum List  »  Optimizer & Parser

Re: Select last row that is less than or equal to a date
Posted by: David Marcus
Date: January 27, 2013 12:00PM

I may run this query up to 50,000 times in a PHP script on my Web server.

There are 97 rows for HistoryPlayer = 59161. There are 71 with HistoryDate <= '2012-01-01'. There are none with HistoryDate = '2012-01-01'. HistoryDate <= '2012-01-01', the returned values are


I did not run any other queries between what I showed you. I just tried it again and got identical results.

By the way, I now think MySQL is executing the query fine. Turns out my script was slow because I had a temporary table that I was running lots of update queries against. I didn't specify the engine, so when my hosting company upgraded to a recent version of MySQL, this became an InnoDB table. Each update was taking around 0.1 seconds. I changed it to engine=memory and now it is back to what it used to be.

Options: ReplyQuote

Written By
Re: Select last row that is less than or equal to a date
January 27, 2013 12:00PM

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.