我们的搜索速度很慢。我们无法在视图上定义索引..请帮助我们如何改进这个..下面的查询花了33.3993秒。
SELECT
`v_cat_pro`.`product_id`, `v_cat_pro`.`msrp`,
FROM
`v_prod_cat` AS `v_cat_pro`
WHERE
(product_status="1" and msrp >0 AND (search_text = 'de') )
ORDER BY
`msrp` ASC LIMIT 50
解释查询结果
id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE cat_product index catproducts_product_id,category_product_index category_product_index 8 NULL 941343 Using index; Using temporary; Using filesort 1 SIMPLE dept eq_ref PRIMARY PRIMARY 4 newdhf.cat_product.category_id 1 Using where 1 SIMPLE team eq_ref PRIMARY PRIMARY 4 newdhf.dept.parent_id 1 Using where 1 SIMPLE league eq_ref PRIMARY PRIMARY 4 newdhf.team.parent_id 1 Using where 1 SIMPLE product eq_ref PRIMARY PRIMARY 4 newdhf.cat_product.product_id 1 Using where
CREATE
算法=未定义的视图v_prod_cat
AS
选择
dept
。id
AS dept_id
,team
。short_name
AS shortteamname
,team
。url
AS {{ 1}},team_url
。team
AS id
,team_id
。league
AS id
,league_id
。{{1} } AS product
,product_id
。product_id
AS product
,product_status
。product_status
AS product
,upload_image_l
。 upload_image_l
AS dept
,name
。department
AS team
,name
。team
AS league
,{{ 1}}。name
AS league
,product
。title
AS title
,cat_product
。product_url
AS {{1} },product_url
。product
AS discount
,discount
。product
AS discount_start_date
,discount_start_date
。product
AS discount_end_date
,discount_end_date
。product
AS extra_discount
,extra_discount
。product
AS extra_discount_start_date
,extra_discount_start_date
。{{ 1}} AS product
,extra_discount_end_date
。extra_discount_end_date
AS product
,global_alt_tag
。global_alt_tag
AS product
,{{1} }。msrp
AS msrp
,if((product
。cost
> 0),1,0)AS cost
,
concat(product
。vendor_id
,_ utf8'',vendor_id
。cat_product
,_ utf8'',is_default
。is_default
,_ utf8 '',替换(替换(替换(替换(league
。name
,'$ leaguename',team
。name
),'$ teamname',{{1} }。dept
),'$ shortteamname',name
。product
),'$ departmentname',title
。league
),'',{{ 1}}。name
,_ utf8'',替换(替换(替换(替换(team
。name
,'$ leaguename',team
。short_name
), '$ teamname',dept
。name
), '$ shortteamname',product
。sku_code
), '$ DepartmentName的',product
。{ {1}}))AS site_search_keyword
这
(((league
name
加入team
name
on(({team
。short_name
= dept
。{{1 }}和(name
。search_text
= _utf8'team'))))加入categories
dept
on((categories
。{{1} } = team
。team
)和(id
。dept
= _utf8'league'))))加入parent_id
team
(() category_type
。categories
= league
。league
)))加入id
team
on(parent_id
。{{1} } = league
。category_type
)))其中(category_products
。cat_product
= _utf8'department')
订购
cat_product
。category_id
desc;
答案 0 :(得分:0)
如果您为' v_prod_cat'添加索引。您正在搜索的列上的表格,这将有助于加快您的观看速度。