You write a long transaction at user code level. Once you run your code, you load objects from the database into your object managers cache. You manipulate the objects, and then you have say 55 dirty objects in your object manager [You+95 ]. If you start a naive traversal of the object manager telling each object to "write itself down to the database" this will result in at least 55 calls to the database with all the call overheads discussed in the Cluster Read pattern. Happy waiting!
How do you speed up the process of writing dirty objects to the database?
Performance: Implementing some bundling here is absolutely necessary - it's not even a matter of discussing this against implementation cost. If you don't do it, performance will be below anything that's reasonable.
Pick up all the statements generated by query objects (physical views) and send them to the database as a single packet of statements
Figure
17:
Calling a Cluster Read Query
The tuple layer needs to support bundling write requests. This bundle manager needs reset, queueStatement, start, and getErrorState operations. Result handling needn't be complicated as you never expect a result for an update or insert statement except an error code.
Using the Bundled Write pattern will result in a single bundled statement issued to the database resulting in improved performance.
Performance: will be reasonable. By the way - what do you call a pattern that MUST be applied in a client/server environment?
Cost: The bundle manager is straightforward and adds only little code.
Cluster Read is a form of bundling requests. The interesting questions is, why can't you use the identical implementation for both Cluster Read and Bundled Write. The answer is: If you request a result of a read you want it immediately and not at some later time, when the access layer decides to execute your query and get your objects. When you flush the object manager at the end of a transaction (i.e. when Bundled Write occurs), you have to wait the dirty objects must be written in a single logical transaction.
Most
object/relational access layers use this pattern, e.g. TopLink [TOP97a
] or the HYPO Project [Kel+98b
]