Skip to content

Commit

Permalink
add max_wal_size and add version selector
Browse files Browse the repository at this point in the history
  • Loading branch information
le0pard committed Jan 25, 2016
1 parent ebd71e0 commit 25c7e70
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 20 deletions.
16 changes: 8 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,16 @@ GEM
mime-types-data (3.2015.1120)
mini_magick (4.3.6)
mini_portile2 (2.0.0)
minitest (5.8.3)
minitest (5.8.4)
multi_json (1.11.2)
net-sftp (2.1.2)
net-ssh (>= 2.6.5)
net-ssh (3.0.1)
nokogiri (1.6.7.1)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
oily_png (1.2.0)
chunky_png (~> 1.3.1)
oj (2.14.2)
oj (2.14.3)
padrino-helpers (0.12.5)
i18n (~> 0.6, >= 0.6.7)
padrino-support (= 0.12.5)
Expand All @@ -147,13 +147,13 @@ GEM
activesupport (= 4.2.5)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
rb-fsevent (0.9.6)
rake (10.5.0)
rb-fsevent (0.9.7)
rb-inotify (0.9.5)
ffi (>= 0.5.0)
redcarpet (3.3.3)
redcarpet (3.3.4)
ref (2.0.0)
sass (3.4.20)
sass (3.4.21)
sprockets (2.12.4)
hike (~> 1.2)
multi_json (~> 1.0)
Expand Down Expand Up @@ -204,4 +204,4 @@ DEPENDENCIES
tzinfo

BUNDLED WITH
1.10.6
1.11.2
18 changes: 17 additions & 1 deletion source/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ title: PgTune
<div class="large-6 medium-6 columns">
<h3 class="calculator-title">Parameters of your system</h3>
<form id="pgTuneForm" action="/">
<!-- db version begin -->
<div class="row">
<div class="large-12 columns">
<label for="pgtDbVersionValue">DB Version
<span class="right">
<span data-tooltip class="has-tip" title="PostgreSQL version">what is this?</span>
</span>
</label>
<select class="radius" id="pgtDbVersionValue">
<% ["9.5", "9.4", "9.3", "9.2", "9.1", "9.0"].each do |v| %>
<option value="<%= v %>"><%= v %></option>
<% end %>
</select>
</div>
</div>
<!-- db version end -->
<!-- os type begin -->
<div class="row">
<div class="large-12 columns">
Expand Down Expand Up @@ -133,7 +149,7 @@ title: PgTune
</div>
</div>
<div id="oldPostgresBlock">
<p><span class="label-for-info">NOTICE:</span> For PostgreSQL &lt; 9.3 you also should modify <a href="http://www.postgresql.org/docs/devel/static/kernel-resources.html" target="_blank">kernel resources</a> (add this in <kbd>/etc/sysctl.conf</kbd>):</p>
<p><span class="label-for-info">NOTICE:</span> For PostgreSQL <span class="pg_version">9.3</span> you also should modify <a href="http://www.postgresql.org/docs/devel/static/kernel-resources.html" target="_blank">kernel resources</a> (add this in <kbd>/etc/sysctl.conf</kbd>):</p>
<div class="row">
<div class="large-12 columns">
<pre class="last-code-block"><code id="postgresOldkernelOut" class="language-ini"></code></pre>
Expand Down
36 changes: 25 additions & 11 deletions source/javascripts/pgtune.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Pgtune

# generate config
_generateConfig: =>
@dbVersion = parseFloat($('#pgtDbVersionValue').val())
@osType = $('#pgtOsTypeValue').val()
@osType = 'linux' if jQuery.inArray(@osType, ['linux', 'windows']) is -1

Expand Down Expand Up @@ -128,14 +129,23 @@ class Pgtune
else
infoMsg = "# WARNING\n# this tool not being optimal \n# for low memory systems\n"

# checkpoint_segments
gConfig['checkpoint_segments'] = {
web: 32,
oltp: 64,
dw: 128,
desktop: 3,
mixed: 32
}[@dbType]
if @dbVersion < 9.5
# checkpoint_segments
gConfig['checkpoint_segments'] = {
web: 32,
oltp: 64,
dw: 128,
desktop: 3,
mixed: 32
}[@dbType]
else
gConfig['max_wal_size'] = {
web: (1024 * @constSize['MB'] / @constSize['KB']),
oltp: (2048 * @constSize['MB'] / @constSize['KB']),
dw: (4096 * @constSize['MB'] / @constSize['KB']),
desktop: (100 * @constSize['MB'] / @constSize['KB']),
mixed: (1024 * @constSize['MB'] / @constSize['KB'])
}[@dbType]
# checkpoint_completion_target
gConfig['checkpoint_completion_target'] = {
web: 0.7,
Expand Down Expand Up @@ -170,16 +180,20 @@ class Pgtune
# postgresql kernel
_kernelSettings: =>
if 'windows' is @osType
$('#oldPostgresBlock').hide()
kernelBlockEl = $('#oldPostgresBlock')
if 'windows' is @osType or @dbVersion > 9.3
kernelBlockEl.hide()
else
shmall = Math.floor(@totalMemory / 8192)
gConfig = """
kernel.shmmax=#{shmall * 4096}
kernel.shmall=#{shmall}
"""
@oldPgkernel.text(gConfig)
$('#oldPostgresBlock').show()
kernelBlockEl.find('.pg_version').text(@dbVersion)
kernelBlockEl.show()
# highlight code
_hightlightCode: =>
Expand Down

0 comments on commit 25c7e70

Please sign in to comment.