Re: Handling Blobs with libpq - Mailing list pgsql-interfaces

From Nigel J. Andrews
Subject Re: Handling Blobs with libpq
Date
Msg-id Pine.LNX.4.21.0303202135500.10910-100000@ponder.fairway2k.co.uk
Whole thread Raw
In response to Handling Blobs with libpq  (Stéphane Pinel <spinel@noos.fr>)
Responses Re: Handling Blobs with libpq  (Joe Conway <mail@joeconway.com>)
List pgsql-interfaces
On Thu, 20 Mar 2003, Stéphane Pinel wrote:

> What is the best approach to handle blobs with libpq ?
>
> I've read in documentation that there are 2 ways:
>
> 1- Bytea
> 2- Larges objects (lo_import)
>
> My main need is storing pictures (like Jpegs etc) or small blobs. Doc
> says that (2) is more
> appropriate but I need to work with blobs in memory, not from files.
>

FWIW, from some tests I ran with PHP bytea is slower and can be several times
slower. Depending on the data the escaping can increase the data size for
transmission up to 4 times. (Can that be right? I'm sure I saw a factor of 4
but can't find the graph now.) That is obviously going to slow the query
transmission/result reception and also cause the backend some work. Indeed, my
tests showed simple retrieving of data files stored as bytea to be
slower than doing the same thing with lo_s with the degree of slow down
proportional to the increase in data size caused by the escaping.

I'm not sure how much of this is down to the escaping/unescaping operations
specifically but that is irrelevent because they're part of the operation to
get what's wanted and what lo_s deliver naturally.

Also, someone recently pointed out that even with bytea if the client encoding
is different when selecting than it was when storing there is still a chance
that your data will be come out different to how it should.


--
Nigel J. Andrews



pgsql-interfaces by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: I want to send comments to the backend!
Next
From: Joe Conway
Date:
Subject: Re: Handling Blobs with libpq