PERF: run full vacuum every 90 days (during migration)
Will reclaim space and improve perf
This commit is contained in:
parent
44d45c6eda
commit
ae2d80501a
|
@ -971,6 +971,8 @@ en:
|
||||||
enable_cdn_js_debugging: "Allow /logs to display proper errors by adding crossorigin permissions on all js includes."
|
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."
|
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:
|
errors:
|
||||||
invalid_email: "Invalid email address."
|
invalid_email: "Invalid email address."
|
||||||
invalid_username: "There's no user with that username."
|
invalid_username: "There's no user with that username."
|
||||||
|
|
|
@ -709,6 +709,11 @@ uncategorized:
|
||||||
company_short_name: 'Unconfigured Forum'
|
company_short_name: 'Unconfigured Forum'
|
||||||
company_domain: 'www.example.com'
|
company_domain: 'www.example.com'
|
||||||
|
|
||||||
|
vacuum_db_days: 90
|
||||||
|
last_vacuum:
|
||||||
|
default: 0
|
||||||
|
hidden: true
|
||||||
|
|
||||||
tos_topic_id:
|
tos_topic_id:
|
||||||
default: -1
|
default: -1
|
||||||
hidden: true
|
hidden: true
|
||||||
|
|
|
@ -2,6 +2,22 @@
|
||||||
task 'db:migrate' => 'environment' do
|
task 'db:migrate' => 'environment' do
|
||||||
I18n.locale = SiteSetting.default_locale rescue :en
|
I18n.locale = SiteSetting.default_locale rescue :en
|
||||||
SeedFu.seed
|
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
|
end
|
||||||
|
|
||||||
task 'test:prepare' => 'environment' do
|
task 'test:prepare' => 'environment' do
|
||||||
|
|
Loading…
Reference in New Issue