neilfurry Posted January 30, 2016 Share Posted January 30, 2016 Hi Mate, I need advice on my query any inputs is highly appreciated. i have this query on the system that im developing, im using a jquery autosearch api here. $sql = 'SELECT referrals.clientid,fullname, firstname, lastname,email,referredby,hearaboutus,gatecode, address1,city,state,zip, homephone, workphone, cellphone,company FROM referrals INNER JOIN address ON address.clientid=referrals.clientid WHERE referrals.firstname is not null ';for($i = 0; $i < $p; $i++) { $sql .= ' AND fullname LIKE ' . "'%" . mysql_real_escape_string($parts[$i]) . "%' ";} My query seems making the search function slow to respond... is there any adjustments on that sql statemet that you can advice to make it search faster. im searching of about 20K of clients on my database. Thanks in advance Neil Quote Link to comment Share on other sites More sharing options...
Barand Posted January 30, 2016 Share Posted January 30, 2016 One query killer you have in there is " ... LIKE '%XXX%' ... " That leading "%" will prevent the query from using an index so every record must be scanned. Without knowing the exact nature of the search (what is in the $parts array?) I can't say more, except, maybe, try a FULLTEXT search Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.