Jump to content

Recommended Posts

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.