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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:17:49+00:00 2026-06-12T00:17:49+00:00

We have a MongoDB collection containing nearly 40 million records. The current size of

  • 0

We have a MongoDB collection containing nearly 40 million records. The current size of the collection is 5GB. The data stored in this collection contains following fields:

_id: "MongoDB id"
userid: "user id" (int)
mobile: "users mobile number" (int)
transaction: "transaction id" (int)
sms: "message sent to user mobile" (text)
created_dt: "unix timestamp of the transaction"

Apart from the index on _id (created by default), we have defined separate indexes on the mobile and transaction fields.

However, the following query takes anywhere between 60 to 120 seconds to complete:

{
    mobile:<users mobile number>
}

I access MongoDB using RockMongo. MongoDB is hosted on a server with 16GB RAM. Nearly 8GB RAM on this server is free.

What is it that I am doing wrong here?

Update:

Output of explain:

{
    "cursor" : "BasicCursor",
    "nscanned" : 37145516,
    "nscannedObjects" : 37145516,
    "n" : 37145516,
    "millis" : 296040,
    "nYields" : 1343,
    "nChunkSkips" : 0,
    "isMultiKey" : false,
    "indexOnly" : false,
    "indexBounds" : {
    }
}

Output of mongostat at the time of the query

insert  query update delete getmore command flushes mapped  vsize    res faults locked % idx miss %     qr|qw   ar|aw  netIn netOut  conn       time 
    13      2      0      0       0       1       0   168g   336g  6.86g      1        1          0       0|0     1|0    21k     1k    19   11:30:04 
    16      0      0      0       0       1       0   168g   336g  6.88g      0      0.1          0       0|0     1|0    21k     1k    19   11:30:05 
    14      0      0      0       0       1       0   168g   336g  6.86g      0        0          0       0|0     1|0    29k     1k    19   11:30:06 
    10      0      0      0       0       1       0   168g   336g  6.86g      0        0          0       0|0     1|0    19k     1k    19   11:30:07 
    16      0      0      0       0       1       0   168g   336g  6.88g      0      0.1          0       0|0     1|0    21k     1k    19   11:30:08 
     9      0      0      0       0       1       0   168g   336g  6.89g      0        0          0       0|0     1|0    13k     1k    19   11:30:09 
    19      0      0      0       0       1       0   168g   336g  6.89g      0        0          0       0|0     1|0    27k     1k    19   11:30:10 
    12      0      0      0       0       1       0   168g   336g  6.89g      1      1.2          0       0|0     1|0    24k     1k    19   11:30:11 
    17      0      0      0       0       1       0   168g   336g  6.89g      1      1.7          0       0|0     1|0    31k     1k    19   11:30:12 
    15      0      0      0       0       1       0   168g   336g  6.89g      0        0          0       0|0     1|0    19k     1k    19   11:30:13 

Update 2:

Until recently, we used to store another collection with about 1.3 billion documents in the same MongoDB server. This collection has now been removed (dropped). This may explain the mapped / vsize column in above output from mongostat.

The server also stores 6 other collections which have frequent inserts. The total storage size currently is about 35GB.

Update 3:

Indexes defined on the collection. Created using RockMongo.

[
{
    "v" : 1,
    "key" : {
        "_id" : 1
    },
    "ns" : "mymongodb.transaction_sms_details",
    "name" : "_id_"
},
{
    "v" : 1,
    "key" : {
        "_transaction_mobile_" : 1
    },
    "ns" : "mymongodb.transaction_sms_details",
    "background" : 1,
    "name" : "mobile"
},
{
    "v" : 1,
    "key" : {
        "_transaction_transaction_" : 1
    },
    "ns" : "mymongodb.transaction_sms_details",
    "background" : 1,
    "name" : "transaction"
}
]
  • 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-12T00:17:50+00:00Added an answer on June 12, 2026 at 12:17 am

    The keys generated by RockMongo is apparently incorrect.

        "_transaction_mobile_" : 1
        "_transaction_transtion_" : 1
    

    I don’t know what’s wrong with RockMongo, but I think this can fix the issue:

    db.xxx.dropIndexes();
    db.xxx.ensureIndex({mobile: 1});
    db.xxx.ensureIndex({transaction: 1});
    

    Notice: This may take VERY LONG time. Don’t do this on a running production machine.

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

Sidebar

Related Questions

Assuming I have a collection in MongoDB with 5000 records, each containing something similar
I have a MongoDB collection with data that was not saved through my Derby
I have a collection of articles in MongoDB that has the following structure: {
I have an existing MongoDB collection containing user names. The user names contain both
I have a collection in MongoDB with 20 million documents and an index created
I have a MongoDB collection called employees where there are documents like this: {
I have a MongoDB collection with documents in the following format: { _id :
I have a MongoDB collection which has a created_at stored in each document. These
Using Node.js, mongoDB, mongoose: I have a db collection whos records have field of
i have a mongoDB collection named col that has documents that look like this

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.