Oracle Blobs - store size or calculation?

I write a shared Http resource hosting service and save large objects as BLOBs in an Oracle database. I want to be able to set the "Content-Length" header when returning the saved object, which means that I need to know the BLOB size before I start writing it to the client (I know I can use chunked-encoding, and in some cases) . Does anyone have any performance experience caused by calling dbms_lob.getlength () for each read, or should I calculate the BLOB size on INSERT and save it in a table? On average, I expect writing rates to be higher than reading rates. Now I am writing a benchmark to try to understand what it is, but it seems like such a general question, which, as I thought, someone already understood this. Also, using JDBC / Spring 3,how would I even calculate the blob size for writing? (and I cannot use triggers or stored procedures) Thanks.

+5
source share
3 answers

I did a quick check by selecting BLOB from the table and then LENGTH (BLOB) and DBMS_LOB.GETLENGTH (BLOB). When choosing the BLOB itself, I got 44 consecutive results. When I selected the length (using any method), I got 7 consecutive hits.

Based on this, when I get the length, it does not extract the entire block and calculates the length. It is reasonable to assume that the length stored at the beginning of the BLOB (for example, the length of VARCHAR2 is stored), and this is used directly.

Thus, there should be no large overhead in determining the length, and not its storage. It also reduces the chance of inconsistency.

+6
source

BLOBS , : -

  • BLOB. java BLOB
  • uncompress , BLOB , ,

, BLOB .

+2

.

, ( , , ). , , , - , , ( .length() LOT).

0

All Articles