mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
PERF: run full vacuum every 90 days (during migration)
Will reclaim space and improve perf
This commit is contained in:
parent
44d45c6eda
commit
ae2d80501a
3 changed files with 23 additions and 0 deletions
|
@ -971,6 +971,8 @@ en:
|
|||
enable_cdn_js_debugging: "Allow /logs to display proper errors by adding crossorigin permissions on all js includes."
|
||||
show_create_topics_notice: "If the site has fewer than 5 public topics, show a notice asking admins to create some topics."
|
||||
|
||||
vacuum_db_days: "Run VACUUM FULL ANALYZE to reclaim DB space after migrations (set to 0 to disable)"
|
||||
|
||||
errors:
|
||||
invalid_email: "Invalid email address."
|
||||
invalid_username: "There's no user with that username."
|
||||
|
|
|
@ -709,6 +709,11 @@ uncategorized:
|
|||
company_short_name: 'Unconfigured Forum'
|
||||
company_domain: 'www.example.com'
|
||||
|
||||
vacuum_db_days: 90
|
||||
last_vacuum:
|
||||
default: 0
|
||||
hidden: true
|
||||
|
||||
tos_topic_id:
|
||||
default: -1
|
||||
hidden: true
|
||||
|
|
|
@ -2,6 +2,22 @@
|
|||
task 'db:migrate' => 'environment' do
|
||||
I18n.locale = SiteSetting.default_locale rescue :en
|
||||
SeedFu.seed
|
||||
|
||||
if SiteSetting.vacuum_db_days > 0 &&
|
||||
SiteSetting.last_vacuum < (Time.now.to_i - SiteSetting.vacuum_db_days.days.to_i)
|
||||
puts "Running VACUUM FULL ANALYZE to reclaim DB space, this may take a while"
|
||||
puts "Set to run every #{SiteSetting.vacuum_db_days} days (search for vacuum in site settings)"
|
||||
puts "#{Time.now} starting..."
|
||||
begin
|
||||
|
||||
Topic.exec_sql("VACUUM FULL ANALYZE")
|
||||
rescue => e
|
||||
puts "VACUUM failed, skipping"
|
||||
puts e.to_s
|
||||
end
|
||||
SiteSetting.last_vacuum = Time.now.to_i
|
||||
puts "#{Time.now} VACUUM done"
|
||||
end
|
||||
end
|
||||
|
||||
task 'test:prepare' => 'environment' do
|
||||
|
|
Loading…
Reference in a new issue