How to make mysql query fast while searchs with like
hi friends please consider my problem and give solution. i have three
table. it have to search three table with like match..the query search
10,000 records and gives results.it works fine but take 4seconds to give
results.
please give better solution to make it 1second..
profile_category_table
----------------
restaurant
sea food restaurant
------------------------
profile_keywords_table
-------------------------
rest
restroom
--------------
company_profile_table
-------------------
maha restaurants
indian restaurants..
Query:
select name from ( (SELECT PC_name as name FROM profile_category_table
WHERE PC_status=1 and PC_parentid!=0
and ( regex_replace('[^a-zA-Z0-9\-]','',remove_specialCharacter(PC_name))
LIKE '%rest%' ) GROUP BY PC_name ) UNION (SELECT PROFKEY_name as name
FROM profile_keywords_table WHERE PROFKEY_status=1
and (
regex_replace('[^a-zA-Z0-9\-]','',remove_specialCharacter(PROFKEY_name))
LIKE '%rest%' ) GROUP BY PROFKEY_name )
UNION (SELECT COM_name as name FROM company_profile_table
WHERE COM_status=1 and (
regex_replace('[^a-zA-Z0-9\-]','',remove_specialCharacter(COM_name))
LIKE '%rest%' ) GROUP BY COM_name ) )a
ORDER BY IF(name LIKE '%rest%',1,0) desc
LIMIT 0,25<br><br>
table engine:myisam;
And I add INDEX FOR THAT columns too.. how to optimize my query to execute
fast..
thnks..
No comments:
Post a Comment