-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path04_pagination.rb
47 lines (39 loc) · 1.09 KB
/
04_pagination.rb
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require 'active_record'
require 'sequel'
require 'benchmark'
require 'pg'
require 'logger'
require 'rom'
require 'rom-sql'
require 'rom-repository'
Benchmark.bm do |x|
x.report('ActiveRecord'.ljust(15)) do
class User < ActiveRecord::Base
establish_connection("postgres:///brainwashing_users")
self.table_name="users_sequel"
end
User.find_each do |user|
user
end
end
x.report("Sequel".ljust(15)) do
DB = Sequel.postgres("brainwashing_users")
DB.extension :pagination
DB[:users_sequel].each_page(1000).each do |dataset|
dataset.each { |user| user }
end
end
x.report("Sequel Cursor".ljust(15)) do
DB2 = Sequel.postgres("brainwashing_users")
DB2[:users_sequel].use_cursor(rows_per_fetch: 1000).each { |user| user }
end
x.report("ROM".ljust(15)) do
rom = ROM.container(:sql, "postgres:///brainwashing_users") do |conf|
class Users < ROM::Relation[:sql]
schema(:users_rom, infer: true, as: :users)
end
conf.register_relation(Users)
end
rom.relations[:users].dataset.all.each{|el| el; }
end
end