I'm very very sorry, I produced an error with the last commit on this file: there was an error in parenthesis position on line 117. Line 117 should be as line 131.
(But how did I manage to make this wrong ???)
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).