Re: Saving a jpg into Postgresql table

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Gibson <gibson(at)nexgenstudio(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Saving a jpg into Postgresql table
Date: 2006-08-24 13:45:49
Message-ID: 20060824134548.GA6584@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2006-08-24 14:01:05 Re: invalid byte sequence ?
Previous Message Alvaro Herrera 2006-08-24 13:45:23 Re: invalid byte sequence ?