Re: Handling Blobs with libpq

From: "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk>
To: Stéphane Pinel <spinel(at)noos(dot)fr>
Cc: PostgreSQL-interfaces <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: Handling Blobs with libpq
Date: 2003-03-20 21:44:36
Message-ID: Pine.LNX.4.21.0303202135500.10910-100000@ponder.fairway2k.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Joe Conway 2003-03-20 21:49:42 Re: Handling Blobs with libpq
Previous Message Bruce Momjian 2003-03-20 19:09:26 Re: I want to send comments to the backend!