Take the 2-minute tour ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

Here is the query in the Rails console:

database=application_database collection=posts selector={"merchant_id"=>"51c3a84b9727911738000003", "status"=>{"$nin"=>["10", "8"]}, "admin_id"=>{"$nin"=>[nil, "0"]}, "start_date"=>{:$gte=>2014-12-26 06:00:00 UTC}, "end_date"=>{:$lte=>2015-01-02 06:00:00 UTC}} flags=[:slave_ok] limit=0 skip=0 batch_size=nil fields=nil (45.3529ms)

Can anyone recommend a way to better optimize this query ? I have an index for this particular query:

{
        "v" : 1,
        "key" : {
            "merchant_id" : 1,
            "admin_id" : 1,
            "start_date" : 1,
            "status" : 1
        },
        "name" : "merchant_id_1_admin_id_1_start_date_1_status_1",
        "ns" : "application_database.posts",
        "background" : true
    }

But it's still taking longer to dip this than it is to render the enter view file for the customers (28 ms just for the view). I'd like to provide a better experience to our customers.

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.