Should I calculate percentages in MySQL or in an application?

I am writing a Rails application that does a lot of calculations on imported pay-per-click advertising data. Imported logs containing impressions, clicks, conversions, etc. are stored in one massive log table, which then needs to be combined with a conversion table to calculate the cost-per-conversion, conversion rate for each campaign. Execution in MySQL seems fast enough (400 ms), but is there a reason for this in the application, and not at the database level?

Thanks!

+4
source share
2 answers

The mysql math parser is pretty fast, as it basically calls low-level c functions to do the math. However, it makes some rounding errors in large-scale calculations that will be acceptable for most use cases.

+1
source

. this is what databases were invented for.

+2
source

All Articles