olalat188
25-04-2014, 13:28
Xin chào các bạn. hồi đầu trang web chạy nhanh như gió, nó gặp vấn đề khi số bản ghi lên con số 10k. view log lên thì thấy có 1 số truy vấn như sau nó làm chậm . các bạn có cách nào đổi sang câu truy vấn tương đương.mà time nó nhỏ hơn ko. rất mong được giúp đỡ. Trong file log đa số là các câu truy vấn như vầy:
# Query_time: 1.070044 Lock_time: 0.000000 Rows_sent: 20 Rows_examined: 3295
SET timestamp=1398137227;
SELECT `id`, `name`, `url`
FROM `articles`
WHERE (active=1) AND (`cid` IN (2041, 2048, 2047, 2046, 2045, 2044, 2043, 2042, 2066))
ORDER BY `time` DESC LIMIT 20;
# Query_time: 0.890023 Lock_time: 0.000000 Rows_sent: 6 Rows_examined: 11243
SET timestamp=1398133597;
SELECT `name`
FROM `articles`
WHERE active=1 ORDER BY time DESC LIMIT 6;
# Query_time: 0.838008 Lock_time: 0.000000 Rows_sent: 6 Rows_examined: 11243
SET timestamp=1398102545;
SELECT *
FROM `articles`
WHERE active=1
ORDER BY `comments` DESC LIMIT 6;
# Query_time: 1.070044 Lock_time: 0.000000 Rows_sent: 20 Rows_examined: 3295
SET timestamp=1398137227;
SELECT `id`, `name`, `url`
FROM `articles`
WHERE (active=1) AND (`cid` IN (2041, 2048, 2047, 2046, 2045, 2044, 2043, 2042, 2066))
ORDER BY `time` DESC LIMIT 20;
# Query_time: 0.890023 Lock_time: 0.000000 Rows_sent: 6 Rows_examined: 11243
SET timestamp=1398133597;
SELECT `name`
FROM `articles`
WHERE active=1 ORDER BY time DESC LIMIT 6;
# Query_time: 0.838008 Lock_time: 0.000000 Rows_sent: 6 Rows_examined: 11243
SET timestamp=1398102545;
SELECT *
FROM `articles`
WHERE active=1
ORDER BY `comments` DESC LIMIT 6;