Re: Saving a jpg into Postgresql table - Mailing list pgsql-general

From Michael Fuhr
Subject Re: Saving a jpg into Postgresql table
Date
Msg-id 20060824134548.GA6584@winnie.fuhr.org
Whole thread Raw
In response to Saving a jpg into Postgresql table  (Gibson <gibson@nexgenstudio.com>)
List pgsql-general
On Thu, Aug 24, 2006 at 06:25:28PM +0800, Gibson wrote:
> I have a projects using ASP.NET (VB.net) where i upload a jpeg file
> using a web form and then save the jpeg file into a table. I've decided
> to use "Oid" instead of "Bytea" as i heard that "Oid" is more memory
> efficient.

See the Large Objects documentation:

http://www.postgresql.org/docs/8.1/interactive/largeobjects.html

You can read a large object in chunks, but if you need to assemble
those chunks into a complete object then you might not end up saving
much memory.  Bytea can be easier to work with, so before committing
to using large objects I'd recommend evaluating whether you really
have a problem that they'll solve.

> So can anyone point me to a website or link where i can see
> the VB.net or C# code that does the SQL insert of the jpeg file into the
> "Oid" data type column and also how to do a SQL select to retrieve and
> display the image on a web form? Thanks

What client library are you using?  Npgsql?  If so then see "Working
with large object support" in the documentation:

http://npgsql.projects.postgresql.org/docs/manual/UserManual.htm

I see the following in that documentation:

  Warning:  There is a known issue when working with bytea datatype
  and large data. Npgsql will consume very much memory. Please, if
  you need to insert more that 4MB of data, please, use Large Object
  API. For updates on this issue, check here"

The link leads to a closed bug report entitled "Enormous memory
increase (and application crash) with large BYTEA parameter."  You
might wish to read the comments to see if and how the problem has
been addressed.

--
Michael Fuhr

pgsql-general by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: invalid byte sequence ?
Next
From: Tom Lane
Date:
Subject: Re: invalid byte sequence ?