最近Plnetで遅いクエリが溜まっていってあっという間にmax-connectionに到達してたんですが、mysqldumpslow(slowログをサマリしてくれるヤツ)で一番重いのを修正したら調子が良くなった。
Webサーバの死活監視にmontasticを使い始めたとたんに携帯にメールが糞来まくって追い詰められ、重い腰をやっと上げた結果です・・・。
sudo mysqldumpslow /var/log/mysql/mysql-slow.log
Count: 4 Time=104.75s (419s) Lock=0.00s (0s) Rows=1.0 (4), plnet[plnet]@local
host
SELECT COUNT(e.id) AS CNT
FROM member_to_feed m2f
JOIN feed f ON m2f.feed_id = f.id
JOIN entry e ON f.id = e.feed_id
WHERE DATE_FORMAT(e.date, 'S') = 'S'
AND m2f.member_id = 'S'
Count: 5 Time=73.00s (365s) Lock=0.00s (0s) Rows=12.0 (60), plnet[plnet]@loca
lhost
SELECT e.id, e.uri, e.title, e.description, e.author,
UNIX_TIMESTAMP(e.date) AS date,
f.title AS feed_title, f.link AS feed_link,
f.uri AS feed_uri, f.favicon
FROM member_to_feed m2f
JOIN feed f ON m2f.feed_id = f.id
JOIN entry e ON f.id = e.feed_id
WHERE DATE_FORMAT(e.date, 'S') = 'S'
AND m2f.member_id = 'S'
ORDER BY e.date DESC LIMIT N, N