My team and I have a strange problem with MySQL queries. We use the SELECTc operator COUNTand for some reason is pretty “fast” in the client used (SQLyog), but it is very slow when we use PHP.
We tried to use ancient mysql_query (), the mysqli extension, and we also tried to use PDO, but all of this did not help.
In other posts here at Stackoverflow, we found that this could be a DNS problem, and that this could be fixed using "skip_name_resolve" in my.ini, but we already had this in our configuration.
Temporary results:
Client: 2,092 with PHP: 9.1071 sec
This is the request we use:
SELECT SQL_NO_CACHE
COUNT(m.mm_id) AS total
FROM
db.media_multimedia m
WHERE m.cat_id IN
(SELECT
mc.cat_id
FROM
db.media_multimedia_category mc
WHERE mc.cat_active = 1)
AND m.mm_published = 1
AND (
m.mm_title LIKE "%denniy%"
OR m.mm_text LIKE "%denniy%"
OR m.mm_id IN
(SELECT
a.mm_id
FROM
db.`media_tag_multimedia` a
LEFT JOIN media.`media_tag` b
ON a.`tag_id` = b.tag_id
WHERE b.tag_name LIKE "%denniy%")
)
AND m.mm_publishing_date >= "2012-04-24 00:00:00"
AND m.mm_publishing_date <= "2013-04-24 23:59:59" ;
* . SQL_NO_CACHE , , . *
PHP MYSQL:
MySQL: 5.1.61
PHP: 5.3.3
?