Subject Re: Picture Servlet Problems possibly OT
Author Roman Rokytskyy
Hi,

> Thanks for the code. I did some test setting the buffer the same
> size as the segment size in the db.
>
> I can't seem to see a performance difference between doing what you
> suggested or simply using
>
> sos.write(result_set.getBytes(1));
>
> The average time from the above was like 1 milliseconds faster than
> the code you provide?
> ...
>
> When the buffer was larger, 32767 the segment size of blobs in the
> db, it seems performance degraded. I did not test out any other
> combinations between 2048-32767.

Blobs are fetched from the database by blocks, not segments. This is
very interesting thing, because the actual API call is
isc_get_segment. However, you specify size you want to get from
database (max. is Short.MAX_VALUE - 2). Size of the buffer is
controlled by connection parameter "blob_buffer_size" (probably
undocumented one), and by default is 1024 * 16.

So, using any buffer of size less than "blob_buffer_size" in your code
makes a little sense, since it is already buffered in driver. Bigger
buffers cause additional fetch. So, in general, let the driver decide
how to fetch blobs from database.

There is another thing that influences performance, socket input and
output buffer sizes. These are set by default to the OS settings, but
in some Linux-es (probably related to kernel version), they are
"incorrect" (performance is very low). They are controlled by
connection parameter "isc_dpb_socket_buffer_size". On Windows optimal
value is 8k, seems that on Linux 8k and 16k are ok. Higher values
decrease the performance.

Best regards,
Roman Rokytskyy