|Lesson 8||Buffering LOBs |
|Objective||Discern when to buffer LOBs. |
In Oracle, you can use a technique known as buffering LOBs. You buffer LOBs on the client side of a connection rather than the server side.
This practice means that once you fetch a LOB, it is stored locally on the client machine. The process of using client-side buffering is illustrated in the following Slide Show:
lob Buffering Process
When you use LOB buffering, you can keep a buffer of up to 512 KB on the client. This buffer is used for all buffered LOBs on the client.
Buffering LOBs has advantages and disadvantages.
Advantages of buffering LOBs
When you buffer a LOB, a client application can work on the LOB, updating it as many times as it wants, without forcing a roundtrip to the server to store the changes. The reduction in roundtrips to the server can improve performance, especially because the update of a LOB can involve the transfer of a large amount of data. In addition to the reduction in network requirements, buffering LOBs can reduce the logging overhead of your Oracle server, because fewer changes to a large object require less logging of those changes.
Disadvantages of buffering LOBs
There are many disadvantages to using LOB buffering. The basic problem comes from the fact that once you move a LOB to a client-side buffer, your Oracle server is out of the picture, as far as data management goes, until you update the LOB back to the server by flushing the buffer. Because of this, you have to create you own solutions for a number of data management issues:
- Because your Oracle server doesn't know what is happening on the client, you have to manage concurrency explicitly by locking
the buffered LOB yourself.
- You have to handle transaction control and any potential errors yourself.
- Client-side buffering can be implemented only through the Oracle Call Interface (OCI), a fairly low-level C code application program
- You cannot use the
DBMS_LOB procedures with a buffered large object, which can further increase your coding burden.
When to buffer LOBs
As you can tell, a significant amount of coding is needed to use a client-side buffer for large objects. You will probably want to take
advantage of this technique only when a particular circumstance dictates that the implementation effort is justified–
a situation where, without buffering, you would be frequently updating the same LOB. For instance, if you were working on a particular image in an image editor, you might want to buffer it on the client until all your changes were completed.
At the same time, you should make sure that the same situation does not call for shared use of the buffered LOB, because the lack of
concurrency control, error handling, and transaction control can present insurmountable obstacles when buffering large objects that are shared in real time.
The next lesson is the conclusion of the module.
LOB Storage - Quiz