Created
July 19, 2017 09:11
-
-
Save zymtx5g79k/7437eff46b7c84ac972974c6757e150e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
# frozen_string_literal: true | |
require 'benchmark' | |
require 'pg' | |
conn = PG.connect host: '127.0.0.1', dbname: 'dbname', user: 'root', password: 'root' | |
# conn = PG.connect host: '127.0.0.1', dbname: 'dbname', user: 'postgres', password: 'postgres', port: 12548 # container | |
values = [] | |
query = 'SELECT * FROM users LIMIT 1000' | |
measure = Benchmark.measure do | |
conn.exec(query).each do |row| | |
values << row | |
end | |
end | |
puts "'#{query}' => #{measure}", values.map(&:to_json).join(' ')[0..800] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment