谁能帮我优化这个查询并帮我调整 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
在我重新启动服务器并且查询不在 chache 后执行大约需要 5 秒。我在以下位置有索引:表 product_feeds 到 pf_id(主)列 表 raw_feed 到 rf_row_id(主)和 rf_search_index 列
解释后我得到:
*************************** 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
谁能帮我重新配置这个文件并帮我查询?
我使用具有 10GB 根存储、1.7GB(RAM?)内存的亚马逊 aws ec2 小型实例
谢谢