From 838062eee13993fc3c666400671254c85c97f5d6 Mon Sep 17 00:00:00 2001 From: Pascal Vibet Date: Tue, 15 Sep 2015 10:57:04 +0200 Subject: [PATCH 1/3] Support optimization for postgresql --- lib/tasks/db_raw.rake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/tasks/db_raw.rake b/lib/tasks/db_raw.rake index 3b65df55b..457a145ee 100644 --- a/lib/tasks/db_raw.rake +++ b/lib/tasks/db_raw.rake @@ -61,6 +61,12 @@ namespace :db do puts "* #{table}" ActiveRecord::Base.connection.execute("OPTIMIZE TABLE #{table}") end + when 'postgresql' + puts "Optimizing tables, this may take a while:" + for table in ActiveRecord::Base.connection.tables.sort + puts "* #{table}" + ActiveRecord::Base.connection.execute("VACUUM FULL ANALYZE #{table}") + end else raise "Don't know how to optimize for database engine: #{adapter}" end From f2f006585d94526f19dadc3fda003821e00a7106 Mon Sep 17 00:00:00 2001 From: Pascal Vibet Date: Tue, 15 Sep 2015 10:54:31 +0200 Subject: [PATCH 2/3] Change call method to list mysql tables in optimize task --- lib/tasks/db_raw.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/db_raw.rake b/lib/tasks/db_raw.rake index 457a145ee..9daa16393 100644 --- a/lib/tasks/db_raw.rake +++ b/lib/tasks/db_raw.rake @@ -57,7 +57,7 @@ namespace :db do case adapter when 'mysql', 'mysql2' puts "Optimizing tables, this may take a while:" - for table in ActiveRecord::Base.connection.select_values('SHOW TABLES').sort + for table in ActiveRecord::Base.connection.tables.sort puts "* #{table}" ActiveRecord::Base.connection.execute("OPTIMIZE TABLE #{table}") end From c3b4ebc6b6b683fc0cc6d22a0622e2cc00bdb7ae Mon Sep 17 00:00:00 2001 From: Pascal Vibet Date: Tue, 15 Sep 2015 12:18:26 +0200 Subject: [PATCH 3/3] Update README and CONTRIBUTORS --- CONTRIBUTORS.md | 1 + README.markdown | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 74ea48ffa..62edc6672 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -34,6 +34,7 @@ Contributors * Nick Fagerlund * Nick Lewis * Nigel Kersten +* Pascal Vibet * Patrick Carlisle * Paul Berry * Peter Meier diff --git a/README.markdown b/README.markdown index 5b85bb698..981135081 100644 --- a/README.markdown +++ b/README.markdown @@ -73,7 +73,7 @@ bundle install --deployment ```` * You need to create a secret for production and either set it via environment variable: `export SECRET_KEY_BASE=$(bundle exec rails secret)` - or follow the instructions in config/secrets.yml to setup an encrypted secret. + or follow the instructions in config/secrets.yml to setup an encrypted secret. * Setup database and pre-compile assets ```` RAILS_ENV=production bundle exec rake db:setup && \ @@ -96,9 +96,17 @@ precompile assets for production using: * `SECRET_KEY_BASE=none RAILS_ENV=production bundle exec rails assets:precompile` +Dashboard will keep all reports in the database. If your infrastructure is big the database will +eventually become very large (more than 50GB). To periodically purge old reports (~ once per day) +and optimize the database tables (~ once per month) it is recommended to run the following tasks +periodically: + + * `SECRET_KEY_BASE=none RAILS_ENV=production bundle exec rails reports:prune upto=20 unit=day` + * `SECRET_KEY_BASE=none RAILS_ENV=production bundle exec rails db:raw:optimize` + Contributing ------------ -To contribute to this project, please read [CONTRIBUTING](CONTRIBUTING.md). -A list of contributors is found in [CONTRIBUTORS](CONTRIBUTORS.md). Thanks! +To contribute to this project, please read [CONTRIBUTING](CONTRIBUTING.md). +A list of contributors is found in [CONTRIBUTORS](CONTRIBUTORS.md). Thanks! This project uses the [Silk icons](http://www.famfamfam.com/lab/icons/silk/) by Mark James. Thank you!