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 771343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:38:21+00:00 2026-05-14T18:38:21+00:00

I have a table with 10 columns that need to be searchable (the table

  • 0

I have a table with 10 columns that need to be searchable (the table itself has about 20 columns). So the user will enter query criteria for at least one of the columns but possibly all ten. All non-empty criteria is then put into an AND condition

Suppose the user provided non-empty criteria for column1 and column4 and column8 the query would be:

select * from the_table 
where column1 like '%column1_query%' 
and column4 like '%column4_query%'
and column8 like '%column8_query%'

So my question is: am I better off creating 1 index with 10 columns? 10 indexes with 1 column each? Or do I need to find out what sets of columns are queried together frequently and create indexes for them (an index on cols 1,4 and 8 in the case above).

If my understanding is correct a single index of 10 columns would only work effectively if all 10 columns are in the condition.

Open to any suggestions here, additionally the rowcount of the table is only expected to be around 20-30K rows but I want to make sure any and all searches on the table are fast.

Thanks!

  • 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-14T18:38:22+00:00Added an answer on May 14, 2026 at 6:38 pm
    1. “find out what sets of columns are queried together frequently and create indexes for them” is the best approach.

      Also, order the columns in indexes based on 2 criteria:

      • Columns that are more frequent in where clauses have priority

      • Columns that are more selective have priority.

        E.g. if “where col1=val1” returns an average of 2 rows for a random value val1, but “where col2=val2” returns 2000 rows on average, col1 should have priority as far as being early in index

    2. Not sure about Postgres, but in Sybase, the like '%xxx%' expressions (e.g match value starts with wildcard) do NOT hit the index, EVER. So the index can’t help with that query unless you select those 3 columns and thus make it a covering index.

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

Sidebar

Related Questions

If I have a table that (among other columns) has two DATETIME columns, how
I have a pictures table that has the following columns: PICTURE_ID int IDENTITY(1000,1) NOT
I have a data table 44 columns wide that I need to write to
I have a table called excel that has 3 columns, name , id ,
I have a flattened table that contains columns that represent groups that need to
In SQL Server assuming one has columns that need to have the same data
I have a model that already has a couple dozen of columns that will
I need a select from table which does not have column that tells when
I have a table that holds only two columns - a ListID and PersonID.
Say I have an MSSQL table with two columns: an int ID column that's

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.