Search code examples
javascriptmysqlsearch-engine

Javascript array search engine


I have a mysql DB table of about 10.000 rows and about 20 fields. I have a form with all the fields and when I press a key in any of the field it should filter the 10.000 rows to only those that match what I typed. I don't want to make an AJAX request to the server for every key that I type and I was thinking that I can grab all the data at first and make an array out of it and do the search this way. My question is: Is this a good way to do it or should I stick with good old SQL queries on the databse and do N ajax requests ? You have a better advice ?


Solution

  • You can make incremental searches far more efficient just by adding a half-second pause between a keypress and the actual loading of data. The user probably won't notice, but your server will.

    Of course, if you can add JavaScript-assisted filtering too, that'd be even better. There's no reason why you can't combine the two methods.