Skip to content

Instantly share code, notes, and snippets.

@rafaelss
Created January 15, 2011 17:47
Show Gist options
  • Save rafaelss/781083 to your computer and use it in GitHub Desktop.
Save rafaelss/781083 to your computer and use it in GitHub Desktop.
models
------
class Bookmark
referenced_in :user
end
class User
references_many :bookmarks, :dependent => :destroy
end
index.slim
----------
@bookmarks.each do |bookmark|
...
= bookmark.user.username
...
beta.20 log
-----------
(repeated at least 50 times)
truffls_development['bookmarks'].find({"$or"=>[{:private=>false}, {:private=>true, :user_id=>BSON::ObjectId('4d16ae21a46a2d600b000005')}]}, {}).limit(50).sort([[:created_at, :desc], [:updated_at, :desc]])
truffls_development['users'].find({:_id=>BSON::ObjectId('4d16ae21a46a2d600b000005')}, {}).limit(-1)
beta.20 response time
---------------------
Completed 200 OK in 291ms (Views: 276.6ms)
rc.4 log
--------
(repeated at least 50 times)
truffls_development['bookmarks'].find({"$or"=>[{:private=>false}, {:private=>true, :user_id=>BSON::ObjectId('4d16ae21a46a2d600b000005')}]}, {}).limit(50).sort([[:created_at, :desc], [:updated_at, :desc]])
truffls_development['users'].find({:_id=>BSON::ObjectId('4d16ae21a46a2d600b000005')}, {}).limit(-1)
truffls_development['bookmarks'].find({"user_id"=>BSON::ObjectId('4d16ae21a46a2d600b000005')}, {})
MONGODB cursor.refresh() for cursor 6223321165071467073
rc.4 response time
------------------
Completed 200 OK in 14728ms (Views: 14714.9ms)
@durran
Copy link

durran commented Jan 15, 2011

Thanks for this... Can you try pointing at master and see if that helps it? I expect the relational stuff in the rc's to be slightly slower, but this is ridiculous... I did make a commit that should help this out at:

mongoid/mongoid@6e4df4d

@rafaelss
Copy link
Author

master is freaking fast!

Completed 200 OK in 214ms (Views: 197.7ms)

@durran
Copy link

durran commented Jan 16, 2011

Ok that's a weight off my chest... Thank you very much for providing the gist.

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