ITeye博客

mysql中应该如何添加索引

sky_xin · 2015-09-29 17:50 · mysql · 数据库 · Markdown

例如下面的sql,应该首先添加where条件下apfi.file_id =5082字段的索引,

其次添加bp.single_file_id的字段索引

 

sql如下:

SELECT
	apfi.sw,
	apfi.sh,
	apfi.cx,
	apfi.cy,
	bp.buy_url,
	bp.discount_price AS price,
	bp.price AS old_price,
	bp.id AS product_id,
	CONCAT('single_', sys_item_id) AS id
FROM
	app_polly_file_item apfi
INNER JOIN b_product bp ON apfi.sys_item_id = bp.single_file_id
AND bp.deleted = 0
AND bp.available = 1
WHERE
	apfi.file_id =5082
AND apfi.type = 'sys'
AND apfi.sys_item_type = 'single'
ORDER BY
	apfi.sys_item_id

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。