Skip to content

Instantly share code, notes, and snippets.

@Elffers
Created March 24, 2015 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Elffers/9c658d23d8643d202465 to your computer and use it in GitHub Desktop.
Save Elffers/9c658d23d8643d202465 to your computer and use it in GitHub Desktop.
SQL/Active Record querying
Benchmark.bm do |x|
x.report("sql"){ 5000.times { Person.where(id:2).pluck("created_at").first } }
x.report("sql"){ 5000.times { Person.find(2).created_at } }
end
[#<Benchmark::Tms:0x000001065b1240
@cstime=0.0,
@cutime=0.0,
@label="sql",
@real=1.558864,
@stime=0.11000000000000032,
@total=1.120000000000001,
@utime=1.0100000000000007>,
#<Benchmark::Tms:0x007fb6f5aa6d98
@cstime=0.0,
@cutime=0.0,
@label="sql",
@real=2.011806,
@stime=0.10999999999999943,
@total=1.6899999999999995,
@utime=1.58>]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment