Skip to content

Instantly share code, notes, and snippets.

@norman
Last active September 26, 2015 16:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save norman/1129745 to your computer and use it in GitHub Desktop.
Save norman/1129745 to your computer and use it in GitHub Desktop.
Friendly Id Benchmarks
Git revision: 9b395bad80da30f0101e5df91cc9d18aeac2b3c1
$ BUNDLE_GEMFILE=gemfiles/Gemfile.rails-4.0.rb DB=postgres bundle exec rake bench
------------------------------------------------------------------------
Using ruby 2.0.0 AR 4.0.0 with postgres
Rehearsal ----------------------------------------------------------------------------------
find (without FriendlyId) 0.340000 0.030000 0.370000 ( 0.473857)
find (in-table slug) 0.990000 0.040000 1.030000 ( 1.285145)
find (in-table slug; included FinderMethods) 0.420000 0.020000 0.440000 ( 0.663232)
find (external slug) 1.630000 0.050000 1.680000 ( 2.194663)
insert (without FriendlyId) 1.000000 0.080000 1.080000 ( 1.356241)
insert (in-table-slug) 3.130000 0.130000 3.260000 ( 3.921744)
insert (in-table-slug; included FinderMethods) 1.000000 0.080000 1.080000 ( 1.365883)
insert (external slug) 8.290000 0.310000 8.600000 ( 10.800216)
------------------------------------------------------------------------ total: 17.540000sec
user system total real
find (without FriendlyId) 0.290000 0.030000 0.320000 ( 0.423382)
find (in-table slug) 0.900000 0.030000 0.930000 ( 1.222101)
find (in-table slug; included FinderMethods) 0.430000 0.030000 0.460000 ( 0.703448)
find (external slug) 1.580000 0.040000 1.620000 ( 2.144805)
insert (without FriendlyId) 0.660000 0.070000 0.730000 ( 1.049766)
insert (in-table-slug) 3.060000 0.130000 3.190000 ( 3.845923)
insert (in-table-slug; included FinderMethods) 0.700000 0.070000 0.770000 ( 1.048894)
insert (external slug) 8.350000 0.330000 8.680000 ( 11.089634)
@bartz
Copy link

bartz commented Sep 11, 2011

What tests yielded these benchmarks?

@norman
Copy link
Author

norman commented Sep 11, 2011

@hubsmoke
Copy link

Is there an index on the primary key?

@norman
Copy link
Author

norman commented Sep 22, 2011

In all SQL databases I'm familiar with, primary key constraints are implemented as a unique index. So, unless I'm mistaken in thinking that SQLite3 does this, then yes.

@zorbash
Copy link

zorbash commented Oct 3, 2012

I think @hubsmoke wanted to ask if there is an index on the slug column. Is there?

@dmitry
Copy link

dmitry commented Feb 1, 2013

@zorbash to tell @norman to join a discussion with @hubsmoke you need to use @ symbol. :)

@kfirshay
Copy link

@norman Did you notice that the benchmark specify postgres explicitly. I am confused why we are talking about SQLite here?!

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