In table log_conversion
, revenue
has type FLOAT
. It should be DECIMAL(11, 2)
or similar.
Why not?
Links to any studies? Performance tests? Other known problems?
And today I tried to get all conversions with revenue = 0.29
, which was not possible in SQL using = 0.29
.
Here's a stackoverflow thread about it: https://stackoverflow.com/questions/13030368/best-data-type-to-store-money-values-in-mysql
Since money needs an exact representation don't use data types that are only approximate like float.
Looks like 4 decimals places (to accommodate Chile) would suffice. https://en.wikipedia.org/wiki/ISO_4217
We can't address this issue prior Matomo 4.0, as we try to avoid any schema changes to log tables in minor releases...
Note: We'll only change it for new installs and create an FAQ for existing installs. For more details see https://github.com/matomo-org/matomo/pull/15408/files#r367739574
@sgiehl there are still some floats in other tables like log_conversion which we may want to change. Could also check there if DECIMAL(X,Y)
works nicely for new installs meaning that it won't automatically convert a 5
to a 5.00
when inserting such a record and then selecting these values aren't automatically converted to 5.00
(but I think it does). We would then use double
instead I guess. I suppose float might be too small for some currencies.