任何人都可以幫助我優化這個查詢,並幫助我調整my.cnf文件?優化MySQL查詢,重新配置MY.CNF?
SELECT
rf_row_id,
pf_id,
pf_wordpress_url,
pf_merchant_logo,
rf_desc,
rf_manufacturer,
rf_product_name,
rf_small_image,
rf_price,
pf_name,
rf_shipping_handling_cost,
pf_voucher_code_expiry_date,
pf_voucher_code,
pf_voucher_code_instructions,
rf_last_modified,
pf_last_update,
rf_deep_link,
pf_delivery_free_from,
pf_voucher_code_url,
pf_delivery_string,
pf_delivery_fee_2
FROM raw_feed, product_feeds
WHERE pf_id=rf_feed_id
AND (rf_search_index LIKE '%C4838AE%' OR rf_search_index LIKE '%HP11%')
GROUP BY rf_feed_id, rf_product_id ORDER BY rf_price ASC
我重新啓動服務器後,執行大約需要5秒,查詢不在chache中。 我在指標: 表product_feeds到PF_ID(小學)列 表raw_feed到rf_row_id(小學)和rf_search_index列
EXPLAIN之後,我得到:
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: raw_feed
type: ALL
possible_keys: NULL
key: NULL
key_len: NULL
ref: NULL
rows: 263804
Extra: Using where; Using temporary; Using filesort
*************************** 2. row ***************************
id: 1
select_type: SIMPLE
table: product_feeds
type: eq_ref
possible_keys: PRIMARY
key: PRIMARY
key_len: 2
ref: usrdb_rnbx.raw_feed.rf_feed_id
rows: 1
Extra:
不知道爲什麼第一個關鍵行是空的?我應該創建哪些索引?
我在raw_feed表中有263,804行總數,在product_feeds表中有50行。
my.cnf文件:()
[mysqld]
basedir=/opt/bitnami/mysql
character-set-server=UTF8
collation-server=utf8_general_ci
datadir=/opt/bitnami/mysql/data
port=3306
socket=/opt/bitnami/mysql/tmp/mysql.sock
tmpdir=/opt/bitnami/mysql/tmp
set-variable = max_connections=3096
set-variable = max_allowed_packet=15M
key_buffer = 1024M
key_buffer_size = 1024M
table_cache = 1024
sort_buffer_size = 50M
read_buffer_size = 50M
read_rnd_buffer_size = 16M
myisam_sort_buffer_size = 3M
thread_cache = 32
thread_concurrency = 16
open-files-limit= 261424
set-variable = thread_stack=512k
set-variable = query_cache_size=128M
set-variable = wait_timeout=120
set-variable = interactive_timeout=60
set-variable = max_connect_errors=999999
誰能幫我重新配置這個文件,並幫我查詢?
我使用Amazon AWS EC2小實例與10GB存儲根,1.7GB(RAM?)內存
感謝
爲什麼GROUP BY? –