> Indeed you could do it via a regexp, but that uses up quite some memory. 
> Every time you do a SELECT. You can simply add a table column with the 
> stripped value and let the table update itself (with an ON UPDATE ON 
> INSERT trigger, which takes the input value for the itemID and strips it 
> once).
> When doing this on inputting the value into the database, you save 
> yourself the pain (and performance) of doing it on every SELECT-query.

Excuse me? Somebody suggested a PHP loop to solve a query problem and you are 
saying that REGEXP should not be used?
MySQL caches queries and 100 SELECT with a REGEXP will cost zero after the 
first one if nothing changed inside the table.

At the same time an internal REGEXP is faster than everything else has to move 
out and be parsed after via, probably, the same REGEXP engine. Try some bench.

This problem, imho, is a non-problem, at least not a PHP problem.

How MySQL optimizes internally REGEXPs is not PHP problem as well.

It's like to create a loop to read byte after byte because file_get_contents 
could be memory greedy (if you do that with 1 Gb of file you are you doing 
wrong in any case, logs need to be split as example) or avoid MATCH AGAINST in 
query if we have too many rows because of performances problem (table could be 
slipt as well to optimize performances) ... and these practices to avoid native 
solutions are a bit hilarious, imho.


Drag n’ drop—Get easy photo sharing with Windows Live™ Photos.


Reply via email to