Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Postgresql optimize #373

Merged
merged 3 commits into from
Sep 13, 2018

Conversation

ZeroPointEnergy
Copy link
Collaborator

This is the extracted and rebased postgresql optimization part form the PR #333

README.markdown Outdated
@@ -94,9 +94,14 @@ 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 and optimize the database tables 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`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forget, should these be rake instead of rails here and below?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They both work. I don't know if rails intends to move some of the task off of rake in the future so it is probably best to use the rails command from now on.

README.markdown Outdated
@@ -94,9 +94,14 @@ 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 and optimize the database tables it is recommended to run the following tasks periodically:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's change 50Gb to 50GB.
let's also mention the reports:prune is recommended to be run at least once per day, and the db:raw:optimize should be at least monthly. I think that's what we were using.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, will fix that shortly

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}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to suggest maybe making this just VACUUM ANALYZE but I see it needs a FULL to reclaim disk space, and that's what mysql does in OPTIMIZE TABLE above

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the reclaiming of space is intended here.

@ZeroPointEnergy ZeroPointEnergy changed the title Postgresql optimize [WIP] Postgresql optimize Sep 11, 2018
@ZeroPointEnergy
Copy link
Collaborator Author

I recommend we wait with merging this until we have a first release. This touches code which is not covered by tests and we should add them first and then rebase again. See #379

Copy link
Collaborator

@bwitt bwitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be ok with merging this before the release since it's a fairly straightforward change and brings needed parity for running the dashboard on postgresql (it quickly would get unworkable without this)

@ZeroPointEnergy
Copy link
Collaborator Author

Ok, merging it then.

@ZeroPointEnergy ZeroPointEnergy merged commit d966c60 into sodabrew:master Sep 13, 2018
@ZeroPointEnergy ZeroPointEnergy changed the title [WIP] Postgresql optimize Postgresql optimize Sep 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants