Skip to content

Instantly share code, notes, and snippets.

@jraines
Created November 2, 2010 17:20
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jraines/659961 to your computer and use it in GitHub Desktop.
Save jraines/659961 to your computer and use it in GitHub Desktop.
#testing the speed of creating a new object via the association with mongoid
c = Club.first
####### 43 seconds #######
begin
500.times do |i|
c.people.create(:name => 'Jim')
end
end
####### 1 second #########
begin
club_id = c._id
500.times do |i|
Person.create(:name => 'Jim', :club_id => club_id)
end
end
@xtagon
Copy link

xtagon commented Nov 9, 2010

Why is there such a performance difference?

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