2
可能重複:
How can 「set timestamp」 be a slow query?MySQL的SET時間戳作爲一個慢速查詢
我運行一個Web應用程序和使用PHP和MySQL 5.1的WordPress博客,駐留在VPS服務器上。慢速查詢日誌顯示的項目不應該花很長時間才能完成。奇怪的是,當我點擊我的博客鏈接時,通常需要很長時間才能加載,但在此之後它非常快。然後在幾個小時內再次回到緩慢的第一次點擊。看起來好像「SET timestamp =」查詢幾乎存在於所有慢速條目中。這裏是什麼樣子的例子:
# Time: 110129 4:02:06 # [email protected]: appsadmin[appsadmin] @ localhost [] # Query_time: 1.367264 Lock_time: 0.000043 Rows_sent: 18 Rows_examined: 18 use apps; SET timestamp=1296291726; show tables; # Time: 110129 4:02:07 # [email protected]: wp_user[wp_user] @ localhost [] # Query_time: 0.635450 Lock_time: 0.000041 Rows_sent: 11 Rows_examined: 11 use wordpress_user; SET timestamp=1296291727; show tables; # Time: 110130 4:02:03 # [email protected]: appsadmin[appsadmin] @ localhost [] # Query_time: 0.592159 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0 use apps; SET timestamp=1296378123; SELECT /*!40001 SQL_NO_CACHE */ * FROM `mail_queue`; # Time: 110131 4:02:08 # [email protected]: appsadmin[appsadmin] @ localhost [] # Query_time: 2.789990 Lock_time: 0.000047 Rows_sent: 18 Rows_examined: 18 SET timestamp=1296464528; show tables; # Time: 110131 4:02:09 # [email protected]: wp_user[wp_user] @ localhost [] # Query_time: 0.535981 Lock_time: 0.000041 Rows_sent: 11 Rows_examined: 11 use wordpress_user; SET timestamp=1296464529; show tables; # Time: 110201 3:19:03 # [email protected]: wp_user[wp_user] @ localhost [] # Query_time: 1.401393 Lock_time: 0.000071 Rows_sent: 120 Rows_examined: 145 SET timestamp=1296548343; SELECT option_name, option_value FROM wp_options WHERE autoload = 'yes';
這說明它不符合我的數據庫設計的問題,而是某種配置問題。
SHOW TABLES查詢是不是總是很慢?看起來你正在使用MySQL提供的所有內存,並且這些表正在從緩存中移出,並且必須從磁盤讀取,這很慢。 – 2011-02-01 11:05:44
這不僅僅是SHOW TABLES查詢這樣做,但它確實顯示了很多。有沒有辦法顯示來自MySQL的RAM使用情況? – CrossProduct 2011-02-01 22:00:43