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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:12:49+00:00 2026-05-14T05:12:49+00:00

How does SQL Server determine whether a table column has low cardinality? The reason

  • 0

How does SQL Server determine whether a table column has low cardinality?

The reason I ask is because query optimizer would most probably not use an index on a gender column (values ‘m’ and ‘f’). However how would it determine the cardinality of the gender column to come to that decision?

On top of this, if in the unlikely event that I had a million entries in my table and only one entry in the gender column was ‘m’, would SQL server be able to determine this and use the index to retrieve that single row? Or would it just know there are only 2 distinct values in the column and not use the index?

I appreciate the above discusses some poor db design, but I’m just trying to understand how query optimizer comes to its decisions.

Many 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-14T05:12:49+00:00Added an answer on May 14, 2026 at 5:12 am

    See Statistics Used by the Query Optimizer in Microsoft SQL Server 2005 .

    With 1 value ‘m’ and 999999 ‘f’ the statistics will give a cardinality estimate of 1 for ‘m’, and something close to 1M for ‘f’. But that whether the index will be used or not, there are more factors.

    In general such a low selectivity column does not make sense on an index alone. However, it does make sense as a leftmost column on a more complex index, and even as a leftmost column on the clustered index. And even if a column would make sense for ‘m’ and not for ‘f’, the query auto-parametrization may play a trick on you and generate a plan for a variable @gender instead.

    You’ll have to either read more or give more details. Some good resources are the QO team and team members blogs:

    • QO team blog
    • Conor Cunningham blog
    • Craig Friedman blog
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does SQL Server maintains any history to track table alterations like column add, delete,
Why does Sql server doesn't allow more than one IDENTITY column in a table??
Does SQL Server has an external log file or internal table for attempted connections,
Why does SQL server express 2008 give me this error? CREATE TABLE model (
When I perform a select/Insert query, does SQL Server automatically create an implicit transaction
I am using SDAC components to query a SQL Server 2008 database. It has
Does SQL Server 2008 offer any pre-defined table types for use with table-valued parameters?
How does SQL Server determine the order of the columns when you do a
Does SQL Server 2008 have a a data-type like MySQL's enum ?
Does SQL server expect numbers to be specified with digits from the latin alphabet,

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.