Skip to content

Commit 53ca59b

Browse files
committed
Document inline blobs
See also FirebirdSQL/jaybird#839
1 parent a97d123 commit 53ca59b

File tree

4 files changed

+96
-0
lines changed

4 files changed

+96
-0
lines changed

src/docs/asciidoc/appendices/connectionproperties/connectionproperties.adoc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,21 @@ Specifying a size greater than 65535 may result in additional server roundtrips
144144
Values lower than 512 will use 512 ([.since]_Jaybird 6_). +
145145
Default: `16384`
146146

147+
a|`maxInlineBlobSize` +
148+
`max_inline_blob_size`, `isc_dpb_max_inline_blob_size`
149+
|Maximum size in bytes of inline blobs ([.since]_Jaybird 5.0.8/6.0.2_ [.since]_Firebird 5.0.3_).
150+
A value of `0` disables transmission of inline blobs.
151+
See <<ref-inline-blob>> for more information. +
152+
Default: `65535`, maximum value: ``65535``footnote:[The maximum is decided server-side, and may change in future Firebird versions.]
153+
154+
a|`maxBlobCacheSize` +
155+
`max_blob_cache_size`, `isc_dpb_max_blob_cache_size`
156+
|Maximum size in bytes -- per connection -- of the inline blob cache ([.since]_Jaybird 5.0.8/6.0.2_ [.since]_Firebird 5.0.3_).
157+
A value of `0` disables the cache.
158+
Disabling the cache does not disable transmission of inline blobs: set `maxInlineBlobSize` to `0` to disable transmission.
159+
See <<ref-inline-blob>> for more information. +
160+
Default: `10485760` (10 MiB)
161+
147162
a|`soTimeout`
148163
|Jaybird specific property.
149164
Socket blocking timeout in milliseconds.

src/docs/asciidoc/appendices/systemproperties/systemproperties.adoc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,20 @@ See <<ref-async-fetch>> for more information.
7070
Configures the default value for the `enableProtocol` connection property.
7171
See <<ref-enable-protocol>> for more information.
7272

73+
[#systemproperties-default-inline-blob]
74+
=== Default inline blob property values
75+
76+
[.since]_Jaybird 5.0.8/6.0.2_ +
77+
[.since]_Firebird 5.0.3_
78+
79+
`org.firebirdsql.jdbc.defaultMaxInlineBlobSize`::
80+
Configures the default value for the `maxInlineBlobSize` connection property.
81+
82+
`org.firebirdsql.jdbc.defaultMaxBlobCacheSize`::
83+
Configures the default value for the `maxBlobCacheSize` connection property.
84+
85+
See also <<ref-inline-blob>>.
86+
7387
[#systemproperties-default-report-sql-warnings]
7488
=== Default `reportSQLWarnings` value
7589

src/docs/asciidoc/reference/reference.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ include::statement/asyncfetch.adoc[]
3939

4040
include::statement/generatedkeys.adoc[]
4141

42+
include::statement/inlineblob.adoc[]
43+
4244
include::statement/ignoreproceduretype.adoc[]
4345

4446
include::statement/scrollablecursor.adoc[]
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
[#ref-inline-blob]
2+
=== Inline blobs
3+
4+
[.since]_Jaybird 5.0.8/6.0.2_ +
5+
[.since]_Firebird 5.0.3_
6+
7+
Inline blobs are a performance optimization for reading blobs as part of the query.
8+
9+
When querying a blob column, the row data received from the server contains only the blob id, not the data of the blob.
10+
Without inline blobs, the client will need to retrieve the blob data separately, requiring additional round trips between client and server for each blob.
11+
With inline blobs, small blobs -- default less than 65535 bytes -- are sent together with the row data, and the client can then serve the blob from the data it has locally.
12+
Inline blobs can also increase the effectiveness of wire compression -- if enabled, assuming the blob data compresses well.
13+
14+
In short, inline blobs increase throughput when querying small blobs, especially on high latency network connections.
15+
16+
This is not entirely free:
17+
18+
* Fetching rows itself can be slower as more data is sent for a fetch.
19+
* Caching the inline blobs consumes memory.
20+
+
21+
By default, a maximum of 10 MiB per connection is used for this cache.
22+
23+
If the maximum blob cache size is reached, received inline blobs will be discarded.
24+
For pure Java connections, an inline blob is removed from the cache on first use, or when the transaction associated with the blob ends.
25+
The native client implementation may have different cache eviction rules.
26+
27+
As pure Java connections remove the inline blob from the cache on first use, subsequent attempts to read the same blob -- by getting a different instance of `java.sql.Blob` or through multiple calls to the `ResultSet.getXXX` methods -- will use a server-side blob.
28+
This can also happen if multiple columns or rows, even in different result sets on the same connection, point to the same blob id in the same transaction.
29+
30+
If you execute queries returning blobs, while those blobs are never actually opened, you may fill up the cache and later received inline blobs are then discarded.
31+
Especially in long-running transactions, this may reduce the effectiveness of this feature.
32+
33+
Inline blobs are introduced in Firebird 5.0.3 (protocol 19).
34+
For pure Java connections, you need Jaybird 5.0.8 or higher or Jaybird 6.0.2 or higher.
35+
For native connections, you need _fbclient_ 5.0.3 or higher, irrespective of the Jaybird version;
36+
to configure inline blobs for native connections, you will also need Jaybird 5.0.8 or higher or Jaybird 6.0.2 or higher.
37+
38+
[#ref-inline-blob-config]
39+
==== Configuring inline blobs
40+
41+
There are two connection properties affecting inline blobs:
42+
43+
`maxInlineBlobSize` (aliases: `max_inline_blob_size`, `isc_dpb_max_inline_blob_size`)::
44+
Maximum size in bytes of the blob (default: `65535`). +
45+
A value of `0` will disable sending of inline blobs.
46+
+
47+
The maximum allowed value is decided by the Firebird server, and is currently `65535`;
48+
this may change in the future
49+
+
50+
If a blob is smaller than the specified size, the server will send it inline.
51+
The size includes segment lengths, so the actual maximum blob data received is `_N_ * 2` bytes smaller, where _N_ is the number of segments of the actual blob, or at least one segment for stream blobs.
52+
+
53+
The default can be changed with system property <<systemproperties-default-inline-blob,`org.firebirdsql.jdbc.defaultMaxInlineBlobSize`>>.
54+
55+
`maxBlobCacheSize` (aliases: `max_blob_cache_size`, `isc_dpb_max_blob_cache_size`)::
56+
Maximum size in bytes -- per connection -- of the blob cache (default: `10485760` or 10 MiB). +
57+
A value of `0` will disable the cache, but does not disable sending of inline blobs.
58+
Set `maxInlineBlobSize` to `0` to disable sending of inline blobs.
59+
+
60+
For pure Java, only the data size is counted towards the cache size.
61+
For native, the segment lengths also count towards the cache size.
62+
+
63+
The default can be changed with system property <<systemproperties-default-inline-blob,`org.firebirdsql.jdbc.defaultMaxBlobCacheSize`>>.
64+
65+
Without explicitly setting the connection or system property, native connections will use the default of _fbclient_ (which are currently the same as those of Jaybird).

0 commit comments

Comments
 (0)