I'm implementing the jQuery autocomplete library on a textbox. The SQL query I have in the back end uses a JOIN:
SELECT DISTINCT wcc.ItemCode, gwbo.ItemName FROM TBL1 gwbo
INNER JOIN TBL2 wcc ON gwbo.ItemCode = wcc.ItemCode
WHERE wcc.ItemCode LIKE '$term%' OR gwbo.ItemName LIKE '%$term%'
AND wcc.CountStatus != 2 ORDER BY wcc.ItemCode LIMIT 0, 10
This takes about 25 seconds to get the autocomplete box to populate and display.. However, when I remove the JOIN and just query 1 table, the autocomplete displays almost immediately (of course the data isn't accurate). Why is my join slowing it down so drastically? I need the join.. Is there a way to speed this up that I am missing, or will I need an entirely new implementation?