Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7068529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:20:06+00:00 2026-05-28T05:20:06+00:00

I need to search a text field (varchar 500) on a table with about

  • 0

I need to search a text field (varchar 500) on a table with about 150,000 rows.

The first option I tried was executing a stored procedure directly on the db server which looks something like:

Select p.ProductID, 
    p.ProductDescription, 
    p.SalesPrice 
From Products p 
Where p.ProductDescription Like '%' + @PartialDescription + '%'

The result was pretty slow. Even with index on ProductDescription, performance was not fast enough.

The next solution I came up with works in following steps:

  1. Read the whole Products table into List of Type Product and cache it.
  2. Everytime I need to make a search, I go through the collection and do the string comparision as below

    List<Product> searchResultItems = new List<Product>();
    for (int i = 0; i < cachedProducts.Count; i++)
    {
        Product p = cachedProducts[i];
    
        if (p.Description.IndexOf(partialDescription, StringComparison.OrdinalIgnoreCase)>=0)
        {
            searchResultItems.Add(p);
        }
    }
    return searchResultItems;
    

This solution is little faster than searching it directly into the database.
By caching the table in memory, it avoids database calls to a large extent.
However, its still slow in comparision to the legacy system (built more than 10 years ago on FileMaker).
I do not have access to the source code of legacy system and do not know much about it.

With MS SQL Server 2008 database, code written on C# and cache utilizing ObjectCache on System.Runtime.Caching, I was expecting my solution to easily outperform the legacy system. Embarrassingly, its not the case.
How can I optimize my search method? What am I doing wrong? Above function resides in a WCF Service and is consumed (basicHttpBinding) by a web application without any fancy controls. What can I do to make it faster?

Searching directly into the database, can it be a better solution with any kind of optimizations? How can I optimize it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:20:07+00:00Added an answer on May 28, 2026 at 5:20 am

    Because you are searching on a value with a wildcard prefix, an index will not be able to be used hence it will always be doing a table scan.

    You could look into Full Text Search.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to search in a table that has a text field (named Description)
I have a search text field which searches a particular column in a table,
I need to search throw a text field in mysql from my java application.
I need to create a full-text search form for a database of emails /
I need something in between a full text search and an index search: I
I need to search for all users containing a certain text string in their
I need to do a query that search for a text with 'Nome %
I need to do a search and replace on long text strings. I want
How can I search my sql database for a table that contains a field
If you have a varchar field you can easily do SELECT * FROM TABLE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.