Reputation: 14470
I have an option in my application where some data has search based on the text which input in a textbox.
So I do perform search (Call a stored procedure which take string as input) on textbox text- change
event.
I have reading an article about Improving ADO.NET Performance where I found reducing round trip to database can increase performance.
Is there any better approach for these kinds of situations?
Upvotes: 2
Views: 1157
Reputation: 11697
Not sure if it suits your requirement but you can make a database call and load desired table/s into a dataset and then make calls to dataset locally. If you introduce a delay in firing an event on text change using timer then you are done with your requirement and everything should be fast. We are using this approach in our application and it serves great.
But on other hand, I would like to highlight even this approach is not a great deal to enhance performances. Applications are fast based on their architecture and flow, provided application is considerable in size. But it always great to think of shortcuts in technology.
Upvotes: 1
Reputation: 79
What about using an search indexing implementation? I did this for a very similar problem.
Upon starting my application, I would prime the Lucene index. The index would be refreshed periodically to accomodate changes.
http://www.codeproject.com/Articles/29755/Introducing-Lucene-Net
This is much faster than direct DB calls and is less load on your DB server since the index just has to be primed. Moreover, Lucene supports a very strong set of search criteria.
Upvotes: 0
Reputation: 45096
You leave some guessing as don't know what is returned by search.
You could read the data into a Dictionary where key is the textbox input and value is what the search returns. Then you can use LINQ to search the key.
Upvotes: 0
Reputation: 558
depends on your desired user experiance if every change of the textbox has to trigger an update there is little else you can do. textchanged should not fire for every letter typed but only after the user leaves the textbox and the value has changed
if the user can search on multiple fields but the search behind a button
if this function is used alot and there is not to much data that is rather static you could cache the data in your application and fetch from cache
Upvotes: 0