From: Mate Varga <m@matevarga.net>
To: pg@fastcrypt.com
Cc: Dmitry Igrishin <dmitigr@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: very slow largeobject transfers through JDBC
Date: Mon, 3 Sep 2018 16:38:24 +0200
Message-ID: <CAK4GaZ4dUvRYdqPvSXmEd8XCSnPSDv+XfPzVB9NJv27eRKFerw@mail.gmail.com> (raw)
In-Reply-To: <CADK3HHK6UYc4ovNMn0Zzi13Qi4Gu4fuh-FxjbbMAPrhED02DWg@mail.gmail.com>
References: <CAK4GaZ6+BsNmeiwb=n3NKkrQ-nk51Y0VyVvitUVW602m8dC67w@mail.gmail.com>
<CAAfz9KNii+UZYpjOW59EnJ7WPQuh8ykmvV6whQ7kdP7Xi3Go4A@mail.gmail.com>
<CAK4GaZ7w4yfNCcwcchxJkGc_HC9Pv-s7jzqQh=8t_mV2VqsKCg@mail.gmail.com>
<CADK3HHJ_=qTU4=5RiMGgf0QGxPFD4Z+MKYqzD3p8G99vTS4pbg@mail.gmail.com>
<CAK4GaZ6dAtcAz9bH-eEvUEco1e4CVcdYr3a5qT05nNfQ0vRH-A@mail.gmail.com>
<CADK3HHJgjg2pcG-dh_yv5Hjx36KHhi3tkBYM6VLg+F6vzuCmFQ@mail.gmail.com>
<CAK4GaZ50=X5OrKQBHKBwf6XB17nEXjNVDMxrTu_5+5_BtSe-mA@mail.gmail.com>
<CAK4GaZ7jv1gqXv0TmOOvxMNPPM5xRcV+7M=gF_9ggTr9whMEOQ@mail.gmail.com>
<CADK3HHK6UYc4ovNMn0Zzi13Qi4Gu4fuh-FxjbbMAPrhED02DWg@mail.gmail.com>
Which frame do you refer to?
On Mon, Sep 3, 2018 at 3:57 PM Dave Cramer <pg@fastcrypt.com> wrote:
> Not sure why reading from a socket is taking 1ms ?
>
> Dave Cramer
>
> davec@postgresintl.com
> www.postgresintl.com
>
>
> On Mon, 3 Sep 2018 at 09:39, Mate Varga <m@matevarga.net> wrote:
>
>> Hi,
>>
>> https://imgur.com/a/ovsJPRv -- I've uploaded the profiling info (as an
>> image, sorry). It seems this is a JDBC-level problem. I understand that the
>> absolute timing is not meaningful at all because you don't know how large
>> the resultset is, but I can tell that this is only a few thousands rows +
>> few thousand largeobjects, each largeobject is around 1 kByte. (Yes I know
>> this is not a proper use of LOBs -- it's a legacy db structure that's hard
>> to change.)
>>
>> Thanks.
>> Mate
>>
>> On Mon, Sep 3, 2018 at 11:52 AM Mate Varga <m@matevarga.net> wrote:
>>
>>> Hey,
>>>
>>> we'll try to test this with pure JDBC versus hibernate. Thanks!
>>>
>>>
>>> On Mon, Sep 3, 2018 at 11:48 AM Dave Cramer <pg@fastcrypt.com> wrote:
>>>
>>>>
>>>>
>>>> On Mon, 3 Sep 2018 at 03:55, Mate Varga <m@matevarga.net> wrote:
>>>>
>>>>> Basically there's a class with a byte[] field, the class is mapped to
>>>>> table T and the byte field is annotated with @Lob so it goes to the
>>>>> pg_largeobject table.
>>>>>
>>>>
>>>> Ah, so hibernate is in the mix. I wonder if that is causing some
>>>> challenges ?
>>>>
>>>>
>>>>> The DB is on separate host but relatively close to the app, and I can
>>>>> reproduce the problem locally as well. One interesting bit is that turning
>>>>> of SSL between the app and PSQL speeds up things by at least 50%.
>>>>>
>>>>> Ah, one addition -- the binary objects are encrypted, so their entropy
>>>>> is very high.
>>>>>
>>>>> Any chance you could write a simple non-hibernate test code to time
>>>> the code ?
>>>>
>>>> Dave Cramer
>>>>
>>>> dave.cramer@crunchydata.ca
>>>> www.crunchydata.ca
>>>>
>>>>
>>>>
>>>>> Mate
>>>>>
>>>>> On Sun, Sep 2, 2018 at 12:55 AM Dave Cramer <pg@fastcrypt.com> wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Fri, 31 Aug 2018 at 10:15, Mate Varga <m@matevarga.net> wrote:
>>>>>>
>>>>>>> I see -- we could try that, though we're mostly using an ORM
>>>>>>> (Hibernate) to do this. Thanks!
>>>>>>>
>>>>>>> On Fri, Aug 31, 2018 at 3:57 PM Dmitry Igrishin <dmitigr@gmail.com>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> пт, 31 авг. 2018 г. в 16:35, Mate Varga <m@matevarga.net>:
>>>>>>>> >
>>>>>>>> > Hi,
>>>>>>>> >
>>>>>>>> > we're fetching binary data from pg_largeobject table. The data is
>>>>>>>> not very large, but we ended up storing it there. If I'm copying the data
>>>>>>>> to a file from the psql console, then it takes X time (e.g. a second),
>>>>>>>> fetching it through the JDBC driver takes at least 10x more. We don't see
>>>>>>>> this difference between JDBC and 'native' performance for anything except
>>>>>>>> largeobjects (and bytea columns, for the record).
>>>>>>>> >
>>>>>>>> > Does anyone have any advice about whether this can be tuned or
>>>>>>>> what the cause is?
>>>>>>>> I don't know what a reason of that, but I think it's reasonable and
>>>>>>>> quite simple to call lo_import()/lo_export() via JNI.
>>>>>>>>
>>>>>>>
>>>>>> Can't imagine that's any faster. The driver simply implements the
>>>>>> protocol
>>>>>>
>>>>>> Do you have any code to share ? Any other information ?
>>>>>>
>>>>>> Is the JDBC connection significantly further away network wise ?
>>>>>>
>>>>>>
>>>>>> Dave Cramer
>>>>>>
>>>>>> davec@postgresintl.com
>>>>>> www.postgresintl.com
>>>>>>
>>>>>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: m@matevarga.net, pg@fastcrypt.com, dmitigr@gmail.com
Subject: Re: very slow largeobject transfers through JDBC
In-Reply-To: <CAK4GaZ4dUvRYdqPvSXmEd8XCSnPSDv+XfPzVB9NJv27eRKFerw@mail.gmail.com>
References: <CAK4GaZ6+BsNmeiwb=n3NKkrQ-nk51Y0VyVvitUVW602m8dC67w@mail.gmail.com> <CAAfz9KNii+UZYpjOW59EnJ7WPQuh8ykmvV6whQ7kdP7Xi3Go4A@mail.gmail.com> <CAK4GaZ7w4yfNCcwcchxJkGc_HC9Pv-s7jzqQh=8t_mV2VqsKCg@mail.gmail.com> <CADK3HHJ_=qTU4=5RiMGgf0QGxPFD4Z+MKYqzD3p8G99vTS4pbg@mail.gmail.com> <CAK4GaZ6dAtcAz9bH-eEvUEco1e4CVcdYr3a5qT05nNfQ0vRH-A@mail.gmail.com> <CADK3HHJgjg2pcG-dh_yv5Hjx36KHhi3tkBYM6VLg+F6vzuCmFQ@mail.gmail.com> <CAK4GaZ50=X5OrKQBHKBwf6XB17nEXjNVDMxrTu_5+5_BtSe-mA@mail.gmail.com> <CAK4GaZ7jv1gqXv0TmOOvxMNPPM5xRcV+7M=gF_9ggTr9whMEOQ@mail.gmail.com> <CADK3HHK6UYc4ovNMn0Zzi13Qi4Gu4fuh-FxjbbMAPrhED02DWg@mail.gmail.com> <CAK4GaZ4dUvRYdqPvSXmEd8XCSnPSDv+XfPzVB9NJv27eRKFerw@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox