Skip to content

Commit

Permalink
Merge pull request sous-chefs#188 from hw-cookbooks/work_mem
Browse files Browse the repository at this point in the history
Check to make sure mem is less than con, set work_mem to 1 otherwise.
  • Loading branch information
Aaron Baer committed Oct 6, 2014
2 parents 9565cdb + b81bf22 commit 084fc68
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions recipes/config_pgtune.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,20 @@

# (4) work_mem
# Sets the maximum memory to be used for query workspaces.
work_mem =
{ "web" => mem / con,
"oltp" => mem / con,
"dw" => mem / con / 2,
"mixed" => mem / con / 2,
"desktop" => mem / con / 6
}.fetch(db_type)

node.default['postgresql']['config']['work_mem'] = binaryround(work_mem*1024*1024)
if (mem < con)
work_mem =
{ "web" => mem / con,
"oltp" => mem / con,
"dw" => mem / con / 2,
"mixed" => mem / con / 2,
"desktop" => mem / con / 6
}.fetch(db_type)

node.default['postgresql']['config']['work_mem'] = binaryround(work_mem*1024*1024)
else
log "MAX_CONNECTIONS is greater than Memory allocated. Setting WORK_MEM to 1"
node.default['postgresql']['config']['work_mem'] = 1
end

# (5) maintenance_work_mem
# Sets the maximum memory to be used for maintenance operations.
Expand Down

0 comments on commit 084fc68

Please sign in to comment.