Class: MrTuner

Inherits:
Object
  • Object
show all
Defined in:
lib/mrtuner.rb

Instance Method Summary collapse

Constructor Details

#initialize(type, memory, config = {}) ⇒ MrTuner

Returns a new instance of MrTuner.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/mrtuner.rb', line 5

def initialize(type, memory, config = {})
  @type                      = type.downcase
  @memory                    = memory * 1073741824
  @connections               = config['connections']
  @oversubscribe             = config.key?("oversubscribe") ? config['oversubscribe'] : config['connections']
  @block_size                = config.key?("block_size") ? config['block_size'] : 8192
  @wal_block_size            = config.key?("wal_block_size") ? config['block_size'] : 8192
  @max_locks_per_transaction = config.key?("max_locks_per_transaction") ? config['max_locks_per_transaction'] : 64
  @autovacuum_max_workers    = config.key?("autovacuum_max_workers") ? config['autovacuum_max_workers'] : 3
  @max_prepared_transactions = config.key?("max_prepared_transactions") ? config['max_prepared_transactions'] : 0
  @page_size                 = config.key?("page_size") ? config['page_size'] : 4096
end

Instance Method Details

#display_configObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/mrtuner.rb', line 29

def display_config
  get_config.each do |k,v|
    case k
    when :maintenance_work_mem,:work_mem,:shared_buffers,:effective_cache_size
      puts "#{k} = #{as_size(v)}"
    else
      puts "#{k} = #{v}"
    end
  end
end

#get_configObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/mrtuner.rb', line 18

def get_config
  {
    :max_connections              => max_connections,
    :maintenance_work_mem         => make_round_number(maintenance_work_mem),
    :work_mem                     => make_round_number(work_mem.round),
    :checkpoint_completion_target => checkpoint_completion_target,
    :shared_buffers               => make_round_number(shared_buffers),
    :effective_cache_size         => make_round_number(effective_cache_size),
  }
end