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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:55:48+00:00 2026-05-27T05:55:48+00:00

i have a mongo collection like this: { A2_AboutMe: , A2_Attributes: |av|nv|, A2_Birthday: ,

  • 0

i have a mongo collection like this:


{
"A2_AboutMe": "",
"A2_Attributes": "|av|nv|",
"A2_Birthday": "",
"A2_DateCreated": "2010-11-25 22: 59: 00",
"A2_DateLast": "2011-11-18 12: 09: 36",
"A2_FK_A1_IDPerson": "0",
"A2_Firstname": "José Luis",
"A2_FirstnameC": "Jose Luis",
"A2_Gender": "m",
"A2_IDProfile": "1",
"A2_Keywords": "...|..",
"A2_Lastname": "test - test",
"A2_LastnameC": "_test test",
"A2_Locale": "",
"A2_Middlename": "",
"A2_Name": "José Luis test",
"A2_NameC": "Jose Luis test",
...
}

with indexies on A2_LastnameC and A2_FirstnameC
3.000.000 docs in this collection, 8 GB data storage

following query(PHP) in done in 3-4 sec

$collection->find(array(«A2_FirstnameC» => new MongoRegex("/jose/i")))->sort(array(«A2_LastnameC» => -1))->limit(10)

but sometimes the similar queries are done in less than 100 msec.

what can i do to get this performance each time?

test computer is i7, 8GB Ram(7 is used by mongo), Windows 7

  • 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-27T05:55:49+00:00Added an answer on May 27, 2026 at 5:55 am

    First of all index won’t be used for non-prefix-like, case-insensitive regular expressions. But in the query above index can be used for sorting by A2_LastnameC field so this is fast. Now having the sorted data MongoDB will need to get A2_FirstnameC value and match it against the regexp stopping when there’s 10 matches ready (it will be also relatively fast because it will use index to retrieve the data instead of reading whole documents from disk). Depending on data order it can happen to match the first 10 documents – this is the best case and it will be very fast, the worst case would be the matches to occur on the last 10 docs having to scan all the previous index entries.

    How to speed this up? Either use query that can use index, like: «A2_FirstnameC» => new MongoRegex("/^jose/"). Or you have to use some kind of full-text search. A simple way would be to split the field (A2_Firstname in your case) into words, normalize them (convert to lower case, replace accents) and store as an array. Now an index for the array field will be used to do fast searches.

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

Sidebar

Related Questions

I have many collections of documents in a mongo database that look like this:
Lets say I have mongo documents like this: Question 1 { answers:[ {content: 'answer1'},
I'd like to query a mongo collection for records which either don't have a
I have a collection called contract and I would like to group using a_id
I have an mongo query that looks like the following: {'schedule': {'$elemMatch': {'time': {'$gt':
So lets say I have an array containing a hash like this: [{head=> {title=>$20,000
If I have data in my users collection that looks like: { name: '...',
Sort of a mongo noob, and I have a feeling I am tackling this
In Mongo my understanding is that you can have databases and collections. I'm working
The problem is: I have 3 mongo tables, and I want to migrate data

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.