[Kmymoney-devel] Anyone good with SQL?

Eric A. Bonney mailinglists at vanhlebarsoftware.com
Thu Aug 11 07:13:47 UTC 2011


I need help with speeding up this query. This query is run in my app 
when the user wants to display the ledger view after selecting the 
account. It takes about 3-5 seconds so far to run in my emulator on a 
sqlite database that has about 14k splits, 6500 transactions and 150 
accounts.

Here is the sql query that I am running:
"SELECT transactionId AS _id, payeeId, valueFormatted, memo, postDate, 
name FROM kmmSplits, kmmPayees WHERE (kmmSplits.payeeID = kmmPayees.id 
AND accountId = ? AND txType = 'N') UNION SELECT transactionId, payeeId, 
valueFormatted, memo, postDate, checkNumber FROM kmmSplits WHERE payeeID 
IS NULL AND accountId = ? AND txType = 'N' ORDER BY postDate DESC LIMIT 50"

The '?' get filled in with the actual accountId the user has selected. I 
am currently limiting the return to 50 records as you can see but this 
does nothing to speed up the query, so it might as well be dropped. Is 
there anything I can do make this faster or am I just stuck with this 
being a limitation to the sqlite database?

Thanks,
-Eric


More information about the KMyMoney-devel mailing list