I was wondering what you think is a better solution for a field which searches a table upon every keyup().
- AJAX query to search database table, return results
- AJAX query to search database table, then store results in a session, search session on subsequent requests
- AJAX query to search database table, then store results in a JS object/array, search object/array on subsequent requests
I should note, the table could easily reach 1000 rows but wouldn’t grow to something beyond a few thousand. What is an effective, performance driven way to approach this?
Could this be a good solution?
I think your best bet (making some assumptions based on your comments) would be to cache the results on the server (not session, cache), then consider the lifetime of that cached object. If you are doing a LOT of client side use of that, AND the client side is a browser, you might send it to the client to use after that. Consider that 1000 X 100 would be 100,000 – not huge but still not trial.
If it is a less optimal client such as a mobile device, you may consider something more optimal for that device set.
This is all pretty subjective however.
EDIT: You should be able to structure such that your cache would be used by multiple clients (if they are all the same data set) whereas session would be per user.