String lengths in the SQL backend

Phil Longstaff plongstaff at
Thu Nov 13 13:40:25 EST 2008

On November 13, 2008 10:10:53 am Derek Atkins wrote:
> What exactly is the use-case for using codes as a primary key?
> Keep in mind that the SQL Backend data store is just that, a
> data store.  GnuCash does NOT use database constraints, and
> for Accounts it doesn't even need to use an Index, because GnuCash
> does (should!) load in all the accounts at start time.
> So... All searches on accounts are done in core in the gnucash app
> without looking at the DB backend.

The use case is that one person wants to have another table which stores 
information based on the account code.  I gather there are standard German 
account codes and he wants to key off of them.  Possible alternatives are to 
key off of the account guid, or have a code key but don't require the code key 
in his table to be 2048 long.

BTW, Derek is right that the SQL backend is simply a data store.  When you 
open an SQL db, the entire contents is read in the same way the current XML 
file is read.  Any time you add/delete/edit anything, the change is written to 
the db immediately, so it should help prevent data loss.  Gnucash is not 
written as a database app.  It is written assuming that all data is 
immediately available.  Having an SQL db will open up possibilities, but the 
app will need a lot of work to make use of those possibilities.


More information about the gnucash-devel mailing list