私はライブサーバーと開発サーバーを持っており、ライブサーバーの方が強力で、どちらも同等の負荷を実行しているにもかかわらず、ライブ (開発サーバーではない) サーバーでのクエリの実行速度が 10 倍遅いことがわかりました。ライブサーバーから開発サーバーにバックアップをロードするため、データベース構造の問題ではありません。
どこで不一致を探すことができるかについて、誰かアイデアがありますか? それはMySQLの設定でしょうか?どこから探し始めるべきですか?
ライブサーバー:
mysql> SELECT count(`Transaction`.`id`) as count, sum(`Transaction`.`amount`) as sum, sum(Transaction.citiq_margin+rounding + Transaction.citiq_margin_vat) as Revenue FROM `transactions` AS `Transaction ` LEFT JOIN `meters` AS `Meter` ON (`Transaction`.`meter_id` = `Meter`.`id`) LEFT JOIN `units` AS `Unit` ON (`Meter`.`unit_id` = `Unit` .`id`) WHERE (NOT (`Unit`.`Building_id` IN ('1', '85')) AND NOT (`Transaction`.`state` >= 90)) AND DAY(`Transaction`.` created`) = DAY(NOW()) AND YEAR(`Transaction`.`created`) = YEAR(NOW()) AND (MONTH(`Transaction`.`created`)) = MONTH(NOW()); +------+---------+---------+ | | カウント | 合計 | 収益 | +------+---------+---------+ | | 413 | 3638550 | 409210 | +------+---------+---------+ セットで 1 行 (2.62 秒) [root@mises ~]# アップタイム 17:11:57 アップ 55 日、1 分、1 ユーザー、負荷平均: 0.45、0.56、0.60
開発サーバー (バックアップからのわずかな時間の遅延のため、結果の数は異なります):
mysql> SELECT count(`Transaction`.`id`) as count, sum(`Transaction`.`amount`) as sum, sum(Transaction.citiq_margin+rounding + Transaction.citiq_margin_vat) as Revenue FROM `transactions` AS `Transaction ` LEFT JOIN `meters` AS `Meter` ON (`Transaction`.`meter_id` = `Meter`.`id`) LEFT JOIN `units` AS `Unit` ON (`Meter`.`unit_id` = `Unit` .`id`) WHERE (NOT (`Unit`.`Building_id` IN ('1', '85')) AND NOT (`Transaction`.`state` >= 90)) AND DAY(`Transaction`.` created`) = DAY(NOW()) AND YEAR(`Transaction`.`created`) = YEAR(NOW()) AND (MONTH(`Transaction`.`created`)) = MONTH(NOW()); +------+---------+---------+ | | カウント | 合計 | 収益 | +------+---------+---------+ | | 357 | 3005550 | 338306 | +------+---------+---------+ セットで 1 行 (0.22 秒) [www@smith test] $ アップタイム 18:11:53 アップ 12 日間、1:57、4 ユーザー、負荷平均: 0.91、0.75、0.62
ライブ サーバー (Xeon クアッドコア x 2):
プロセッサ : 7 vendor_id : 純正インテル CPUファミリー:6 モデル : 44 モデル名 : Intel(R) Xeon(R) CPU E5620 @ 2.40GHz ステップ: 2 CPU メガヘルツ: 2395.000 キャッシュサイズ:12288KB 物理 ID : 0 兄弟 : 8 コア ID: 10 CPU コア: 4
開発サーバー (1 x クアッドコア)
プロセッサ : 3 vendor_id : 純正インテル CPUファミリー:6 モデル : 23 モデル名 : Intel(R) Core(TM)2 Quad CPU Q8300 @ 2.50GHz ステップ: 10 マイクロコード: 0xa07 CPU MHz : 1998.000 キャッシュサイズ:2048KB 物理 ID : 0 兄弟 : 4 コア ID: 3 CPU コア: 4
ライブサーバー:
- CentOS 5.7
- MySQL バージョン 5.0.95
開発サーバー:
- ArchLinux
- MySQL バージョン 5.5.25a