Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fwq06-0004M8-Oz for pgsql-general@arkaria.postgresql.org; Mon, 03 Sep 2018 14:38:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fwq04-0007Q6-Vr for pgsql-general@arkaria.postgresql.org; Mon, 03 Sep 2018 14:38:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fwq03-0007PT-2D for pgsql-general@lists.postgresql.org; Mon, 03 Sep 2018 14:38:44 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fwpzz-0007cT-Ab for pgsql-general@lists.postgresql.org; Mon, 03 Sep 2018 14:38:42 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 86B9C219E6 for ; Mon, 3 Sep 2018 10:38:37 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Mon, 03 Sep 2018 10:38:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=matevarga.net; h=cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=vJM8ffvQlqbQP/jKfOUtgdf1tsMyUds9af5wepF7hGI=; b=bcTOGxhb h4DuTEl/tLd2DWeYm4Rj9CBXvMJTE34d3ex050HeFyTzCXc6muaXR1mc+ggaFdS4 8uY5UfoqTjaHlwuABsE66okxP8I0JKDGUf0mYYsTxIQZZySadmuFWsgh6revfuBz 8CXmnRcM/i2E26+ZRjF1Ipp1q47GhH9r/TZ6rmkQET6RyoxoOIGtnVkCbEqFALLX 342ZGd3pJAzvudZEoAftb6Zppmw6xSyZaFUZ2SArAZY1iKwJPMT6s8aOPwLZeM4N Fvfx3rXNYBTLc1QUnUpF10LlESfr9o8JnmkuzmQ8E614i8I06HCeyaEkmEupmkQI JBsAc5jjoh56mw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=vJM8ffvQlqbQP/jKfOUtgdf1tsMyU ds9af5wepF7hGI=; b=m0o0U+WjWTg2JQOi23A2gyJi/Gp6NWmFeMjAbcPyJZXH9 U/lcesGgEEzXhdreAS8pKV3Jl+FQ6uYkgXdP7bUuXlmFp5BC6BZ8w/Em4b1vFowH 57gLXIkD/RE7kokJnkAyq4aJpFlTirgGovEO3wGeDa7zDfSIw92IgB+tiklgEzkL 4aCBeingR6l6tmJ0Jpq3lxFYYftS8KKqibsLVzOF1OfgjbHMJFFvkD0DDXCI23Hh vaCv7IKpakUt/nNfWMPghqOZspYu6z+wMj//ZGwcfIDVGmd1pWFmK1IoDHCitZEA +CMj7vEEZ2Q4KznKB1iR/zZcIfK20tkfD2Oz+IiyQ== X-ME-Proxy: X-ME-Sender: Received: from mail-vk0-f49.google.com (mail-vk0-f49.google.com [209.85.213.49]) by mail.messagingengine.com (Postfix) with ESMTPA id 0A4A41029C for ; Mon, 3 Sep 2018 10:38:37 -0400 (EDT) Received: by mail-vk0-f49.google.com with SMTP id l143-v6so280097vke.1 for ; Mon, 03 Sep 2018 07:38:37 -0700 (PDT) X-Gm-Message-State: APzg51CjQGpMhzLF5ypdnZv14+ES0Bl4Resp9qpDe5tY6Lt1WoKHLKex ZNfRm8A0xOAHqJ+1OSMBS4+4X0y1MeFm+eFchK0= X-Google-Smtp-Source: ANB0VdbjE9b9grRv35TRSsQfV+sysu0JD1wNodH90mDLtYlUh+t6i3uaeqwh7uq94tsd7g8Rc5rXwSN1BWZeRGbO3r8= X-Received: by 2002:a1f:d786:: with SMTP id o128-v6mr14190585vkg.29.1535985516500; Mon, 03 Sep 2018 07:38:36 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Mate Varga Date: Mon, 3 Sep 2018 16:38:24 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: very slow largeobject transfers through JDBC To: pg@fastcrypt.com Cc: Dmitry Igrishin , pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000175e840574f87feb" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --000000000000175e840574f87feb Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Which frame do you refer to? On Mon, Sep 3, 2018 at 3:57 PM Dave Cramer 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 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 larg= e >> 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 kn= ow >> this is not a proper use of LOBs -- it's a legacy db structure that's ha= rd >> to change.) >> >> Thanks. >> Mate >> >> On Mon, Sep 3, 2018 at 11:52 AM Mate Varga 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 wrote: >>> >>>> >>>> >>>> On Mon, 3 Sep 2018 at 03:55, Mate Varga 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 tu= rning >>>>> of SSL between the app and PSQL speeds up things by at least 50%. >>>>> >>>>> Ah, one addition -- the binary objects are encrypted, so their entrop= y >>>>> 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 wrote: >>>>> >>>>>> >>>>>> >>>>>> >>>>>> On Fri, 31 Aug 2018 at 10:15, Mate Varga 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 >>>>>>> wrote: >>>>>>> >>>>>>>> =D0=BF=D1=82, 31 =D0=B0=D0=B2=D0=B3. 2018 =D0=B3. =D0=B2 16:35, Ma= te Varga : >>>>>>>> > >>>>>>>> > Hi, >>>>>>>> > >>>>>>>> > we're fetching binary data from pg_largeobject table. The data i= s >>>>>>>> not very large, but we ended up storing it there. If I'm copying t= he data >>>>>>>> to a file from the psql console, then it takes X time (e.g. a seco= nd), >>>>>>>> fetching it through the JDBC driver takes at least 10x more. We do= n'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 an= d >>>>>>>> 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 >>>>>> >>>>> --000000000000175e840574f87feb Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Which frame do you refer to?

On Mon, Sep 3, 2018 at 3:57 PM Dave Cramer <= pg@fastcrypt.com&= gt; wrote:
Not sur= e why reading from a socket is taking 1ms ?

On Mon, 3 Sep 2018 at 09:= 39, Mate Varga <m@m= atevarga.net> wrote:
Hi,

https://imgur.com/a/ovsJ= PRv -- I've uploaded the profiling info (as an image, sorry). It se= ems 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 larg= eobjects, each largeobject is around 1 kByte. (Yes I know this is not a pro= per use of LOBs -- it's a legacy db structure that's hard to change= .)

Thanks.
Mate
On Mon, Sep 3, 2018 at 11:52 A= M Mate Varga <m@mat= evarga.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 Cr= amer <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 c= lass is mapped to table T and the byte field is annotated with @Lob so it g= oes to the pg_largeobject table.

Ah, so hibernate is in the mix. I wonder if that is causing some challen= ges ?
=C2=A0
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 t= heir entropy is very high.

Any = chance you could write a simple non-hibernate test code to time the code ?= =C2=A0
www.crunchydata.ca
=C2=A0
<= /div>
Mate

On Sun, Sep 2, 2018 at 12:55 AM Dave Cramer <pg@fastcrypt.com> wrote:



On Fri, 3= 1 Aug 2018 at 10:15, Mate Varga <m@matevarga.net> wrote:
I see -- we could try that, though we're mos= tly using an ORM (Hibernate) to do this. Thanks!

On Fri, Aug 31, 2018 at 3:57 PM Dmitry Igris= hin <dmitigr@gmai= l.com> wrote:
=D0=BF=D1=82, = 31 =D0=B0=D0=B2=D0=B3. 2018 =D0=B3. =D0=B2 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 da= ta to a file from the psql console, then it takes X time (e.g. a second), f= etching it through the JDBC driver takes at least 10x more. We don't se= e this difference between JDBC and 'native' performance for anythin= g except largeobjects (and bytea columns, for the record).
>
> Does anyone have any advice about whether this can be tuned or what th= e 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 h= ave any code to share ? Any other information ?

Is= the JDBC connection significantly further away network wise ?
--000000000000175e840574f87feb--