Search code examples
c#sql-serversearchstring-algorithm

How to Store strings to Optimize Searching


I am having a table containing a column of type VARCHAR. I want to search strings inside the column according to user input query. I want to implement Approximate Searching. And my table contains Lacs of records. There are some ways I am thinking I can implement searching.

  1. Load All records in C# and apply searching algorithm on it. (But it will consume too much memory.)

  2. Fetch records individually or in some predefined batch size and apply searching algorithm on it. (But it will establish database connection rapidly, which may downgrade the performance.)

I am sure that, there will be some other mechanism to implement this functionality or some technique to store data so that i can search it faster.

Can anybody give me any better idea, to implement this?


Solution

  • Lucene is one of the best ways to search. You can still store your string in the database, but build a Lucene index out of it and then use it to search.