8000 Dex doesn't recommend indexes when sort operation is provided · Issue #21 · mongolab/dex · GitHub
[go: up one dir, main page]

Skip to content

Dex doesn't recommend indexes when sort operation is provided #21

Open

Description

@Sirtea

Having the following collection:

> db.people.find()
{ "_id" : ObjectId("52779d40ad2f74e0deb3a7cf"), "name" : "Gerard", "age" : 31 }
{ "_id" : ObjectId("52779d83ad2f74e0deb3a7d0"), "name" : "Rose", "age" : 23 }
{ "_id" : ObjectId("52779d9ead2f74e0deb3a7d1"), "name" : "Yuki", "age" : 30 }
> 

I tried some basic queries, for example:

> db.people.find({age:{$gte:30}}).sort({name:1})
> db.people.find({age:{$gte:30}})

Passing the DEX tool to an empty system.profile collection, I can see that there's a suggestion when issuing the second query, but not when using the first one.

With sort operation:

> db.system.profile.drop()
true
> db.setProfilingLevel(2)
{ "was" : 0, "slowms" : 100, "ok" : 1 }
> db.people.find({age:{$gte:30}}).sort({name:1})
{ "_id" : ObjectId("52779d40ad2f74e0deb3a7cf"), "name" : "Gerard", "age" : 31 }
{ "_id" : ObjectId("52779d9ead2f74e0deb3a7d1"), "name" : "Yuki", "age" : 30 }
> db.setProfilingLevel(0)
{ "was" : 2, "slowms" : 100, "ok" : 1 }
> 
(env)gerard@antares:~/projects/dextest$ dex -p mongodb://localhost/test
{
    'runStats': {
        'linesRecommended': 0, 
        'linesProcessed': 1, 
        'linesPassed': 2
    }, 
    'results': []
}
(env)gerard@antares:~/projects/dextest$ 

Without sort operation:

> db.system.profile.drop()
true
> db.setProfilingLevel(2)
{ "was" : 0, "slowms" : 100, "ok" : 1 }
> db.people.find({age:{$gte:30}})
{ "_id" : ObjectId("52779d40ad2f74e0deb3a7cf"), "name" : "Gerard", "age" : 31 }
{ "_id" : ObjectId("52779d9ead2f74e0deb3a7d1"), "name" : "Yuki", "age" : 30 }
> db.setProfilingLevel(0)
{ "was" : 2, "slowms" : 100, "ok" : 1 }
> 
(env)gerard@antares:~/projects/dextest$ dex -p mongodb://localhost/test
{
    'runStats': {
        'linesRecommended': 1, 
        'linesProcessed': 1, 
        'linesPassed': 2
    }, 
    'results': [
        {
            'queryMask': '{"$query":{"age":{"$gte":"<val>"}}}', 
            'namespace': 'test.people', 
            'recommendation': {
                'index': '{"age": 1}', 
                'namespace': 'test.people', 
                'shellCommand': 'db["people"].ensureIndex({"age": 1}, {"background": true})'
            }, 
            'details': {
                'count': 1, 
                'totalTimeMillis': 0, 
                'avgTimeMillis': 0
            }
        }
    ]
}
(env)gerard@antares:~/projects/dextest$ 

Activity

  1. esedor commented on Nov 4, 2013

    @esedor
    Contributor

    Thanks for this detailed report! I'll take a look. One question: Are you working with the HEAD of this Dex repo, or the last release of Dex on pypi?

  2. Sirtea commented on Nov 6, 2013

    @Sirtea
    Author

    Not sure, it was the pypi version, installed via pip in a virtualenv

    (env)gerard@antares:~/projects/dextest$ pip freeze
    Dex==0.6
    PyYAML==3.10
    argparse==1.2.1
    dargparse==0.2.3
    ordereddict==1.1
    pymongo==2.6.3
    wsgiref==0.1.2
    (env)gerard@antares:~/projects/dextest$ 
    
  3. srlowe commented on Jul 29, 2015

    @srlowe

    Any update on this? I'm having the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0