Performance of LargeObject.write() with PreparedStatement.setBlob()

Поиск
Список
Период
Сортировка
От David Wall
Тема Performance of LargeObject.write() with PreparedStatement.setBlob()
Дата
Msg-id 010a01c252a3$9151cfc0$3201a8c0@expertrade.com
обсуждение исходный текст
Список pgsql-jdbc
Another check of the code shows that the LargeObject.write(byte[]) is
efficient with buffers since the entire buffer is being written, whereas
write(byte[] buf,int off,int len) has to create a new buffer and then copies
the data in.  This is probably okay since the assumption is that you
wouldn't use the latter if you wanted to write the entire buffer, and making
a check in each call to see if (off==0 && len=buf.length) to avoid the
buffer creation and copy may be overkill.

Instead, a change to PreparedStatement.setBlob() might be able to do this
with:

    if ( numRead == buf.length )
        los.write(buf);
    else
        los.write(buf,0,numRead);

This is in the loop where the blob is being written out in 4k buffers.  Note
that the call is always a zero-based buffered, and all except the "last"
write of a blob would include a full buffer.  This simple test would reduce
a 4k buffer being created and copied on each los.write call except for the
last one.

Thoughts?
David


В списке pgsql-jdbc по дате отправления:

Предыдущее
От: "David Wall"
Дата:
Сообщение: Re: setBlob loop performance?
Следующее
От: Thomas O'Dowd
Дата:
Сообщение: 7.3 support?