This is my query
SELECT `tbl_user`.`file_id` , `tbl_user`.`folder_id` , `tbl_user`.`user_id` , `tbl_user`.`fathername` , `tbl_user`.`investor_type` , `tbl_user`.`user_name` , `account_id` , `user_witness_id` , `visible` , sum( tbl_user_payment.user_amount ) AS amt, `tbl_user_payment`.`trans_type`
FROM (
`tbl_user`
)
LEFT JOIN `tbl_user_payment` ON `tbl_user`.`user_id` = `tbl_user_payment`.`user_id`
LEFT JOIN `tbl_user_stamp` ON `tbl_user_stamp`.`user_id` = `tbl_user_payment`.`user_id`
WHERE `tbl_user`.`visible` = '1'
AND `tbl_user`.`user_name` LIKE '%1%'
OR `tbl_user`.`file_id` LIKE '%1%'
OR `tbl_user`.`folder_id` LIKE '%1%'
OR `tbl_user`.`fathername` LIKE '%1%'
OR `tbl_user`.`nic` LIKE '%1%'
OR `tbl_user`.`email` LIKE '%1%'
OR `tbl_user`.`city` LIKE '%1%'
OR `tbl_user`.`phone` LIKE '%1%'
OR `tbl_user`.`bank_account` LIKE '%1%'
GROUP BY `tbl_user`.`user_id`
i have indexed all the like values but still my query will take abuot 2 seconds, i dont know why it is doing that.
on my local system it take about 2 seconds first time and then it will take about 0.002 seconds after that
but on live server it will not go less than 2 seconds
Can some one plz help me
and the recods are about 1000 only in user table and user_stamp table and abuot 1200 in user_payment table
Thankx
I would guess that the query cache is not activated on your live server.
You want to check your MySQL live server configuration.
That probably means that caching is turned on on your machine, and turned off on the live machine. Try doing different searches on your local machine, those should all be taking about the same time.
You can Create VIEW on MySQL to collect data from tables instead of using join and select only from the view , that will make your data shown more faster..
Learn more about view Click Here
Using LIKE this way will not use indexes. To make use of indexes, you must search from the begginning of the string ('1%'), or just stop usng LIKE, if you don't really need it. It may run faster on your system due to better specs or/and less load.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.