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

  • Home
  • SEARCH
  • 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 8718055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:26:48+00:00 2026-06-13T06:26:48+00:00

I have two fields a and b , where b has substantially higher selectivity

  • 0

I have two fields a and b, where b has substantially higher selectivity than a.

Now, if I am only querying on both a and b (never on either field by itself), which of the following two indexes is better and why:

  1. {a: 1, b : 1}
  2. {b: 1, a : 1}

Explain seems to return almost identical results, but I read somewhere that you should put higher selectivity fields first. I don’t know why that would make sense though.

  • 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-06-13T06:26:50+00:00Added an answer on June 13, 2026 at 6:26 am

    After doing some further analysis the two indexes are in fact pretty much identical from a performance point of view.

    Really if you are in a similar situation, the real consideration should be whether in the future you might be more likely to query on a alone or b alone, and put that field first in the index.

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

Sidebar

Related Questions

I have two forms. One of which has two fields, the name field, and
I have one table that has two fields - ID1 and ID2 ID1 can
I have a table, myTable that has two fields in it ID and patientID
I have two tables: Folder, Files. Each table has 4 fields: ParentID, ID, Name,
I have a mongo collection which has documents with two fields fieldA and fieldB,
I have two variable TO_DATE and FROM_DATE . My table has two fields DOJ
I have a table for storing the postman coverage area. It has two fields
I'm using Hibernate with Xml mappings. I have an entity that has two fields
In SQL Server, I have two fields, one is primary and has an identity
Suppose that I have two data types Foo and Bar. Foo has fields x

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.