Skip to content

Instantly share code, notes, and snippets.

@olkarls
Created March 8, 2012 19:52
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 olkarls/2003001 to your computer and use it in GitHub Desktop.
Save olkarls/2003001 to your computer and use it in GitHub Desktop.
Simple benchmark for explaining database indexes
require 'mysql2'
require 'benchmark'
user = 'USER'
password = 'PASSWORD'
database = 'benchmark'
client = Mysql2::Client.new(host: 'localhost', username: user, password: password, database: database)
Benchmark.bmbm do |x|
x.report do
(0..99).each do
client.query 'SELECT u.first_name, u.last_name, u.email FROM users u where company_id = 100094'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment