memcached でキャッシュされた低速のクエリがありますが、正常に動作しますが、memcached が停止したかのように mysql で低速のクエリが大量に発生し、Web サイトがダウンすることがあります。
スロー クエリのグラフ: http://i.imgur.com/ReyWe.png
この時点で、30 秒で約 100 件のスロー クエリが取得されました。それは何ですか?クエリ:
# Query_time: 5.942602 Lock_time: 0.010214 Rows_sent: 10000 Rows_examined: 493139
SET timestamp=1335194149;
SELECT story_id FROM dug_stories d WHERE d.story_is_permanent=0 AND
(
(d.story_time>1335190543 AND (d.story_pluses-d.story_minuses) > 5)
OR
( ( (d.story_pluses-d.story_minuses) > 12 OR (d.story_pluses >= 10 AND d.story_minuses<=0) ) AND d.story_cat!=48 AND d.st
ory_cat!=131 AND d.story_cat!=55 AND d.story_cat!=44 AND d.story_cat!=126 AND d.story_cat!=53 AND d.story_cat!=370 AND d.story_cat!=381 AND d.stor
y_cat!=304 AND d.story_cat!=497) OR (d.story_cat=48 AND (d.story_pluses-d.story_minuses) > 9) OR (d.story_cat=131 AND (d.story_pluses-d.story_min
uses) > 8) OR (d.story_cat=55 AND (d.story_pluses-d.story_minuses) > 8) OR (d.story_cat=44 AND (d.story_pluses-d.story_minuses) > 9) OR (d.story_c
at=126 AND (d.story_pluses-d.story_minuses) > 13) OR (d.story_cat=53 AND (d.story_pluses-d.story_minuses) > 8) OR (d.story_cat=370 AND (d.story_pl
uses-d.story_minuses) > 8) OR (d.story_cat=381 AND (d.story_pluses-d.story_minuses) > 8) OR (d.story_cat=304 AND (d.story_pluses-d.story_minuses)
> 8) OR (d.story_cat=497 AND (d.story_pluses-d.story_minuses) > 9)
)
ORDER BY d.story_rating DESC, d.story_time DESC LIMIT 0, 10000;
少し調整されたクエリ (すべての != カテゴリの代わりに、NOT カテゴリ IN (除外するカテゴリのリスト) に変更しましたが、読みやすくするために書式設定されています... また、SET TIMESTAMP 変数はクエリで使用されていませんでした) ...ハードコードされた値でした。
SET timestamp=1335194149;
SELECT
story_id
FROM
dug_stories d
WHERE
d.story_is_permanent = 0
AND ( ( d.story_time > 1335190543 AND d.story_pluses - d.story_minuses > 5 )
OR ( ( d.story_pluses - d.story_minuses > 12
OR ( d.story_pluses >= 10 AND d.story_minuses <= 0 )
)
AND NOT d.story_cat IN ( 44, 48, 53, 55, 126, 131, 304, 370, 381, 497 )
)
OR ( d.story_cat = 44 AND d.story_pluses - d.story_minuses > 9 )
OR ( d.story_cat = 48 AND d.story_pluses - d.story_minuses > 9 )
OR ( d.story_cat = 53 AND d.story_pluses - d.story_minuses > 8 )
OR ( d.story_cat = 55 AND d.story_pluses - d.story_minuses > 8 )
OR ( d.story_cat = 126 AND d.story_pluses - d.story_minuses > 13 )
OR ( d.story_cat = 131 AND d.story_pluses - d.story_minuses > 8 )
OR ( d.story_cat = 304 AND d.story_pluses - d.story_minuses > 8 )
OR ( d.story_cat = 370 AND d.story_pluses - d.story_minuses > 8 )
OR ( d.story_cat = 381 AND d.story_pluses - d.story_minuses > 8 )
OR ( d.story_cat = 497 AND d.story_pluses - d.story_minuses > 9 )
)
ORDER BY
d.story_rating DESC,
d.story_time DESC
LIMIT
0, 10000;
助けてくれてどうもありがとう!そして私の下手な英語でごめんなさい:)