Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP/MySQL database connection priority?

I have a production database where usage statistics reside. This database is responsible for many other things (not just statistics calcs). I use php to periodically roll up different resolutions (day, week, month, year) of interesting statistics in buckets dictated by the resolution.

The php application I've written "completes" its data when its run, such that it will calculate all the rolled-up statistics for the resolutions and periods since it was last run. This is useful if we want to turn this off to debug database performance issues, because I can turn it back on and have it complete its data set independent of the script run frequency (cron job could be moved from daily to weekly, etc).

The problem I have, is the calculations are fairly intensive and drive the QPS of the production database server up. Is there a way to set a "priority" on a particular database connection so that it will only use "off-cycles" to do these calculations?

Maybe a proper response would be to replicate the tables I'm working on into a different stats database, but, unfortunately I don't have the resources in place to attempt such a thing (yet).

Thanks in advance for any help, Josh

like image 855
Josh Avatar asked Mar 25 '10 20:03

Josh


1 Answers

low_priority_updates should do exactly what you need.

like image 79
Robert Greiner Avatar answered Oct 05 '22 22:10

Robert Greiner