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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:39:25+00:00 2026-06-04T16:39:25+00:00

If I have a collection which I query based on fields _id and CreationTimestamp.O

  • 0

If I have a collection which I query based on fields _id and CreationTimestamp.O as below:

var _query = Query.And(
 Query.EQ("_id", "TheId"),
    Query.GT("CreationTimestamp.0", DateTimeOffset.UtcNow.AddMinutes(-15).UtcTicks));

Should I create a compound index on both these fields?
I know _id by default has an index.

I am looking for guidance on best practice i.e. Create a compound index for both fields or just create an index for CreationTimestamp.O as their is already an index on _id

  • 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-04T16:39:26+00:00Added an answer on June 4, 2026 at 4:39 pm

    There’s not much benefit in creating compound index here. Since the selectivity of autocreated index on _id field is 1 (it’s unique index) there’s no reason in having any compound index prefixed with it. The only possible benefit may be the fact MongoDB can use covered index for this query and possibly speedup the things (you need to benchmark on your data to prove this).

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

Sidebar

Related Questions

I have a Hibernate/JPA query which performs a simple query based on an indexed
We are currently implementing a solution where we have a collection which we want
In my application, I have three collection objects which store data. The data which
I have a collection of objects which describe an image-name, its size and it's
I have a collection of arrays which are generated dynamically. What I am trying
Let's say I have a collection of objects which can be sorted using a
Hi I am trying to return a collection which may potentially have null date
I have a collection of static libraries (.lib) files one of which may have
I have a collection (or list or array list) in which I want to
I have a class which contains a static collection that can be used across

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.