public
Last active

Friendly Id Benchmarks

  • Download Gist
benchmarks.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
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)

What tests yielded these benchmarks?

Is there an index on the primary key?

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.

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

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

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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.