2014-08-27 4 views
0

검색 속도가 매우 느리다. 우리는보기에 색인을 정의 할 수 없습니다. 우리가 이것을 향상시킬 수있는 방법을 도와주세요. 아래 쿼리는 33.3993 초 걸렸습니다. dept을 선택 v_prod_cat AS mysql 쿼리가 검색 속도가 느리다.

 
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 

이 ALGORITHM = UNDEFINED VIEW를 만들 쿼리 결과를 설명

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 

. iddept_id, team. short_name AS shortteamname, team. urlteam_url, team. idteam_id, . id AS league_id, product. product_idproduct_id, product입니다. product_statusAS product_status, product. , dept. nameAS department, team. name AS team, . nameAS , product. title, title, cat_product. , product. discountAS discount, product. discount_start_date AS discount_start_date, product. discount_end_datediscount_end_date, product입니다. extra_discount AS extra_discount, product. extra_discount_start_dateextra_discount_start_date, product. , product. global_alt_tag AS global_alt_tag, product. , product. cost, cost, product. vendor_idvendor_id AS, AS is_default ((cat_product. is_default> 0), 0), (league. name, _utf8 '

CONCAT'team. name, _utf8 ', 만약 dept. name, _utf8' ,, (대체 (대체 (대체 (을 product. title, '$의 leaguename'을 대체합니다. name을), '$의 teamname', team. name을), '$의 shortteamname', team을. short_name을), '$의에 DepartmentName', dept. name), '', product. sku_code, _utf8 '', 바꾸기 (바꾸기 (바꾸기 장소 (product. site_search_keyword, '$ leaguename', name), '$ teamname', teamname), '$ shortteamname', team. short_name), '$ departmentname', dept. name)) 에서 search_text

((((categoriesdeptcategoriesteam 가입 (((team. id = dept. parent_id) 및 (team있다. category_type = _utf8'team '))))에 categories 합류 ((.id = team. parent_id) 및 (league. category_type = _utf8'league ')))) ((cat_product. category_id = category_productscat_productdept에 가입. id))) ((product. product_id = productsproductcat_product에 가입. product_id))) (dept. category_type = _utf8'department ') 주문 : dept. id desc;

+0

일반적으로 전체 텍스트 검색은 느린 쿼리와 텍스트 검색에 대한 답변입니다. 그렇지 않으면'= 'des'' 대신에 어쩌면 필요하지 않습니까? –

+0

"인덱스를 정의 할 수 없다"는 것은 무엇을 의미합니까? 뷰가 참조하는 테이블에 인덱스를 정의 할 수 있습니까? – Tim

+0

안녕하세요 Tim, 답장을 보내 주셔서 감사합니다. 참조하는 테이블은 innoDB이며 뷰 "search_text"의 필드가 뷰의 여러 조인에서 조작되었습니다. 어떻게 인덱스를 정의 할 수 있는지 알려주세요 .. 위 쿼리를 설명합니다. –

답변

0

검색중인 열의 'v_prod_cat'테이블에 색인을 추가하면보기 속도가 빨라집니다.

+0

'v_prod_cat'이것은 실제로 뷰입니다. 우리는 인덱스를 정의 할 수 없습니다. @ Simon –

+0

'v_prod_cat'이것은 실제로 뷰입니다. 우리는 인덱스를 정의 할 수 없습니다. @Lajos Veres –

+0

뷰는 그대로 사용되는 테이블입니다. 해당 뷰 내에서 최상의 인덱싱이 적용되지 않을 수 있습니다. 이 뷰 내의 모든 테이블을 실행하여 올바르게 설정되었는지 확인하십시오. – Simon

관련 문제