Autocomplete With Remote Data Sourced From Plain File Vs Database
I'm wondering what'd be faster. Let's say I've about 10K records which I need to search for autocomplete query. I believe I've two options-
- Source the data from a plain file - either plain text or maybe json
- Source data from database (MySQL)
My guess is that reading the text file would be much faster so that I can fetch all the records in one go and then perform search inside array to get relevant results for autocomplete query.
However, there's another thought that a properly indexed database can outperform approach #1.
I wish to know if anyone's faced similar situation and what was the optimum solution. How does the efficiency get affected when the number of records is say 50K or 100K?