Some motive to gnucash mysql database fields are created on varchar structure?

John Ralls jralls at ceridwen.us
Wed Nov 4 09:45:14 EST 2015


> On Nov 3, 2015, at 11:49 AM, Elvis de Freitas <edigitalb at gmail.com> wrote:
> 
> I am analyzing gnucash database and I see that at least some financial
> fields are on text format. Why gnucash use that architecture? And Why it is
> interesting?  I see too that the decimal values are saved as integer
> like(or raw value), for example, 12.50 is saved as 1250 on database.
> 
> Can someone explain it? I really stayed interested with it
> 
> Thank you very much

Numbers are rationals, with two fields for numerator and denominator. This was an early decision and we confirmed its wisdom with some extensive testing in 2014. That showed that the alternative, BCD, is 4-6 times slower than rational for our unit tests. As I’m sure you know, floating point is not acceptable for financial use because it’s not able to exactly represent many decimal fractions.

As for the other fields, GnuCash was designed around the XML file format. SQL is an afterthought bolted on for the 2.4 series. While we’re engaged in rewriting GnuCash to be SQL-centered we’ll likely keep the current schema for backwards compatibility.

Regards,
John Ralls




More information about the gnucash-user mailing list