I have a search function on my site that needs to search through ~2000 items (this table never changes, it will always have the same number of items) stored in MySQL. All it needs to do is search by name or 'LIKE' the name and return the id. I have thought of two approaches to this:
- Query database using ajax on keyup(), this seems like it would be expensive with many people searching
- Send all the data to client as a JSON file when they load the page and search through it using JavaScript to reduce the load on the database
Which approach is better? Or if you have a better approach I am open to suggestions.