{"action":"created","issue":{"url":"https://api.github.com/repos/strongloop/loopback-connector-mongodb/issues/55","labels_url":"https://api.github.com/repos/strongloop/loopback-connector-mongodb/issues/55/labels{/name}","comments_url":"https://api.github.com/repos/strongloop/loopback-connector-mongodb/issues/55/comments","events_url":"https://api.github.com/repos/strongloop/loopback-connector-mongodb/issues/55/events","html_url":"https://github.com/strongloop/loopback-connector-mongodb/issues/55","id":44409794,"number":55,"title":"Default sort order may impact performance on some queries","user":{"login":"mihail-stanchev","id":2863920,"avatar_url":"https://avatars.githubusercontent.com/u/2863920?v=3","gravatar_id":"","url":"https://api.github.com/users/mihail-stanchev","html_url":"https://github.com/mihail-stanchev","followers_url":"https://api.github.com/users/mihail-stanchev/followers","following_url":"https://api.github.com/users/mihail-stanchev/following{/other_user}","gists_url":"https://api.github.com/users/mihail-stanchev/gists{/gist_id}","starred_url":"https://api.github.com/users/mihail-stanchev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mihail-stanchev/subscriptions","organizations_url":"https://api.github.com/users/mihail-stanchev/orgs","repos_url":"https://api.github.com/users/mihail-stanchev/repos","events_url":"https://api.github.com/users/mihail-stanchev/events{/privacy}","received_events_url":"https://api.github.com/users/mihail-stanchev/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/strongloop/loopback-connector-mongodb/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2014-09-30T08:29:01Z","updated_at":"2015-09-15T21:32:31Z","closed_at":null,"body":"If a sort order is not specified a default one by _id is used. This may impact the performance of some queries where a sort is neither needed nor specified upfront. For example, using model.findOne results in the MongoDB connector calling db.collection.find(query).sort({_id:1}).limit(1)\r\nIf the sort part is skipped the result is returned almost immediately using the appropriate indices. However, having the sort in there causes the entire query to slow down. In my case there is only one record matching the given criteria and the sort is not needed.\r\n\r\nWould you consider making the sort order explicit?"},"comment":{"url":"https://api.github.com/repos/strongloop/loopback-connector-mongodb/issues/comments/140553208","html_url":"https://github.com/strongloop/loopback-connector-mongodb/issues/55#issuecomment-140553208","issue_url":"https://api.github.com/repos/strongloop/loopback-connector-mongodb/issues/55","id":140553208,"user":{"login":"mazesoul","id":206234,"avatar_url":"https://avatars.githubusercontent.com/u/206234?v=3","gravatar_id":"","url":"https://api.github.com/users/mazesoul","html_url":"https://github.com/mazesoul","followers_url":"https://api.github.com/users/mazesoul/followers","following_url":"https://api.github.com/users/mazesoul/following{/other_user}","gists_url":"https://api.github.com/users/mazesoul/gists{/gist_id}","starred_url":"https://api.github.com/users/mazesoul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mazesoul/subscriptions","organizations_url":"https://api.github.com/users/mazesoul/orgs","repos_url":"https://api.github.com/users/mazesoul/repos","events_url":"https://api.github.com/users/mazesoul/events{/privacy}","received_events_url":"https://api.github.com/users/mazesoul/received_events","type":"User","site_admin":false},"created_at":"2015-09-15T21:32:31Z","updated_at":"2015-09-15T21:32:31Z","body":"+1\r\n"}}