A Note on Performance
Extending
BookSet to UserBookSet and
adding in Views and Validators
changes the performance characteristics enormously. If our goal is a
simple, general-purpose class around which to write scripts, it may
not be worth doing. The original BookSet can add,
edit, and remove transactions quickly as it keeps them in a list, but
most useful queries involve a loop over the entire set of data. A
running UserBookSet in an interactive application
might have 10,000 transactions in memory, five
Views open, and two Validators.
This means that any addition involves talking to seven other objects,
and an edit involves 14 objects. Naturally, this dramatically slows
bulk operations. However, it dramatically enhances query performance;
a view on the screen displaying month-end balances of every account
might need to redraw only one or two cells of the grid after an edit,
rather than recalculate completely. Think of each running
View as an extra database index, and you
won’t go far wrong.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access