Speeding up reports

Phil Longstaff plongstaff at rogers.com
Mon Mar 9 18:15:04 EDT 2009


On March 9, 2009 12:46:54 pm Andrew Sackville-West wrote:
> On Sun, Mar 08, 2009 at 02:03:57PM -0800, Charles Day wrote:
> > On Sat, Mar 7, 2009 at 3:43 PM, Mike Alexander <mta at umich.edu> wrote:
> > > Has anyone looked at <http://bugzilla.gnome.org/show_bug.cgi?id=573229>
> > > to see if my patch makes any sense?  It speeds up some reports (e.g.
> > > Income Statement) by a factor of 50 or so with largish files.
>
> ...
>
> > Cool!! I'm certainly not any sort of authority on report infrastructure
> > (I've dabbled), but I've read your code changes and the concept looks
> > right to me. Perhaps Christian could comment?
>
> ...
>
> > This really should get exercised more. I'm going to go ahead and at least
> > commit this to trunk. This may be experimental, but I guess that's what
> > trunk is for, and it seems fine to me so far.
>
> Thanks Charles, I've been sitting on that in my inbox for a long time
> not having the time to work on it..
>
> A

At some point, reports (or the underlying support) should be changed to use 
qof_query's which use underlying SQL queries.  SELECT SUM(amount) FROM splits 
WHERE acct_guid = '...' AND tx_guid IN (SELECT guid FROM transactions WHERE 
date < '...') will return the account balance at a certain date.  There's no 
need to load all of the splits.  The db engine can do the work for us.  "date 
< '...'" can be replaced by "date >= '...' AND date < '...') to find the 
difference between balances on 2 dates.

Phil


More information about the gnucash-devel mailing list