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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:23:12+00:00 2026-05-16T21:23:12+00:00

If there is an index on page_type, our_id, date and when querying, db.analytics.find({page_type: ‘ingredients’,

  • 0

If there is an index on

page_type, our_id, date

and when querying,

db.analytics.find({page_type: 'ingredients', ga_date: 
  {$gte : new Date('Wed Sep 08 2010 12:00:00 GMT-0800')}})

db.analytics.find({page_type: 'ingredients', ga_date: 
  {$gte : new Date('Wed Sep 08 2010 12:00:00 GMT-0800')}}).explain()

if our_id is omitted, or date is omitted, it can still use the index, with something like the following in the explain() output:

"our_id" : [
    [
        {
            "$minElement" : 1
        },
        {
            "$maxElement" : 1
        }
    ]
],

even if both our_id and date are omitted, the index can still be used.

However, when page_type is omitted, no index can be used (as shown in explain()). So is it true that in MongoDB, when part of the index is something of a sequence, like number or date, then it can be omitted when querying? Is this true in the relational DB as well, because I think it might be strictly on the 3 fields if that index was based on those 3 fields.

  • 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-16T21:23:14+00:00Added an answer on May 16, 2026 at 9:23 pm

    Those are B-tree indexes, so they can be used for a prefix subset of the columns involved. If you do not have the leading columns, an index range scan (the operation that a B-tree index is primarily used for) is no longer possible. There may be other ways to still use the index (Oracle has fast full scans and skip scans for example), but usually, the index will not be used.

    This reasoning applies to everything that uses B-tree indexes, relational DB or not.

    Again, this does not depend on the type of the column, but on the order of columns in the index. You need to have the leading columns (in your case, you need page_type). If you have many queries without the page_type, consider recreating the index with page_type as the last column (which of course may also have a negative impact on other queries). In general, you need to know what kind of queries you will run before you can design the indexes.

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

Sidebar

Related Questions

On my web site, there is an index page, but if I take out
There is index.php and logo.gif files in my server. I need to change the
I have folder home/admin. In this folder there is index.php. When i access to
There is a Select overload that adds an index to each element of a
There is a byte at a specific index in a byte string which represents
There is a rewrite rule ensuring that all URL's head to index.php and maintain
There are three parties in my design: MSFT orderbook NASDAQ index (need to be
Is there a way to set the selected index of a RadioGroup in android,
Is there a way to get the list index name in my lapply() function?
I've just set up a new webiste http://www.reviewongadgets.com But there is a problem with

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.