@olleharstedt opened this Issue on February 21st 2018

In table log_conversion, revenue has type FLOAT. It should be DECIMAL(11, 2) or similar.

@fdellwing commented on February 21st 2018 Contributor

Why not?

Links to any studies? Performance tests? Other known problems?

@olleharstedt commented on February 21st 2018

Precision. 0.1 + 0.2 != 0.3 in float.

@olleharstedt commented on February 21st 2018

And today I tried to get all conversions with revenue = 0.29, which was not possible in SQL using = 0.29.

@olleharstedt commented on February 21st 2018

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.

@robocoder commented on March 2nd 2018 Contributor

Looks like 4 decimals places (to accommodate Chile) would suffice. https://en.wikipedia.org/wiki/ISO_4217

@sgiehl commented on March 30th 2018 Member

We can't address this issue prior Matomo 4.0, as we try to avoid any schema changes to log tables in minor releases...

@tsteur commented on February 20th 2020 Member

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 commented on March 2nd 2020 Member

@tsteur can we close this issue, now as #15408 is merged, or shall we keep it open as reminder for anything?

@tsteur commented on March 2nd 2020 Member

@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.

Powered by GitHub Issue Mirror