PrestaShop/PrestaShop — pull request #717 by zimmi1 (2013-09-13 08:07:00+00:00)
Title: Speeding up sql queries

Searching for "DATE_ADD(date_add, INTERVAL 30 MINUTE) > now" needs for every line to add 30 minutes to the date. but it is the same operation as comparing "date_add > (now - 30 minutes).
It is faster because there is no DATE_ADD calculation.

The problem:
By profiling speed of my shop, this query appeared after about 3 months always as the absolute slowest query of the shop, needing about 15 to 30 ms to perform, because I have now nearly 700 connections to my shop (and it then browses the 700 lines)

A solution:
Removing DATE_ADD MySql function and using date() and time() functions of php for calculating only once the 30 min. difference.

Using this solution takes it down again to 0.8 to 1.3 ms.

I guess it is the same in case of bots (could be even worse as they can make thousands of connections).