Re: Data type for storing images?

Lists: pgsql-generalpgsql-interfaces
From: ryan(at)paymentalliance(dot)net
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Data type for storing images?
Date: 2001-03-11 18:40:18
Message-ID: 3aabc524.433007942@news.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-interfaces

I am not sure what your exact purpose is, but in doing a lot of web
work with pgsql, I usually just store the full path to the image in a
varchar field and fetch that right into the IMG SRC attribute when I
need to display the image.

I also have modified a simple web based image uploading script so upon
uploading an image it detects the images width and height and inserts
that into the DB as well. The script is written in PHP, let me know
if it would be helpful to send it to you.

Good Luck

-Ryan Mahoney

On Sun, 11 Mar 2001 22:52:53 +0000 (UTC), <drevil(at)sidereal(dot)kz> wrote:

>
>I would like to store some images in my Postgres database. These will
>all be thumbnails, limited to 4k or 5k. I know that PG has an 8k row
>limit, but this should be fine, because there's not much else in the
>row. Which data type could I use to store them, and is there a
>performance cost for having rows that are this big? The system will
>be using PG7.1, btw.
>
>Thanks
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org


From: <drevil(at)sidereal(dot)kz>
To: pgsql-general(at)postgresql(dot)org
Subject: Data type for storing images?
Date: 2001-03-11 22:38:18
Message-ID: 20010311223818.18682.qmail@mailhost.sidereal.kz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-interfaces


I would like to store some images in my Postgres database. These will
all be thumbnails, limited to 4k or 5k. I know that PG has an 8k row
limit, but this should be fine, because there's not much else in the
row. Which data type could I use to store them, and is there a
performance cost for having rows that are this big? The system will
be using PG7.1, btw.

Thanks


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: drevil(at)sidereal(dot)kz
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Data type for storing images?
Date: 2001-03-12 01:48:21
Message-ID: 23574.984361701@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-interfaces

<drevil(at)sidereal(dot)kz> writes:
> I would like to store some images in my Postgres database. These will
> all be thumbnails, limited to 4k or 5k. I know that PG has an 8k row
> limit, but this should be fine, because there's not much else in the
> row. Which data type could I use to store them, and is there a
> performance cost for having rows that are this big? The system will
> be using PG7.1, btw.

bytea is probably your best bet. The 8k limit is toast in 7.1, btw.

regards, tom lane


From: "David Wall" <d(dot)wall(at)computer(dot)org>
To: <drevil(at)sidereal(dot)kz>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Data type for storing images?
Date: 2001-03-12 02:12:29
Message-ID: 001701c0aa99$e419fb00a2b7ad8@expertrade.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-interfaces

> bytea is probably your best bet. The 8k limit is toast in 7.1, btw.

If you're using JDBC, you may not be able to get bytea types to work. I was
able to get the SQL type OID to work with JDBC's get/setBytes() methods.
You may also want to use 7.1 since I believe it's large object support is
improved.

David


From: Frank Joerdens <frank(at)joerdens(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Data type for storing images?
Date: 2001-03-12 10:19:53
Message-ID: 20010312111953.B32676@rakete.joerdens.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-interfaces

On Sun, Mar 11, 2001 at 08:48:21PM -0500, Tom Lane wrote:
[ . . . ]
> bytea is probably your best bet. The 8k limit is toast in 7.1, btw.

Is that whay you named it TOAST, in order to be able to say that? :)))

Regards, Frank


From: Lincoln Yeoh <lyeoh(at)pop(dot)jaring(dot)my>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, drevil(at)sidereal(dot)kz
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Data type for storing images?
Date: 2001-03-13 07:31:21
Message-ID: 3.0.5.32.20010313153121.009643c0@192.228.128.13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-interfaces

At 08:48 PM 11-03-2001 -0500, Tom Lane wrote:
><drevil(at)sidereal(dot)kz> writes:
>> I would like to store some images in my Postgres database. These will
>> all be thumbnails, limited to 4k or 5k. I know that PG has an 8k row
>
>bytea is probably your best bet. The 8k limit is toast in 7.1, btw.

What's bytea ?

How do I store and retrieve 0x00 and other binary stuff like this?

Right now I store stuff like this in files on the filesystem. Storing as
base64 in text doesn't sound attractive :). What are the advantages of
using BLOBs vs files on the filesystem?

Cheerio,
Link.


From: <drevil(at)sidereal(dot)kz>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Data type for storing images?
Date: 2001-03-13 09:00:44
Message-ID: 20010313090044.25147.qmail@mailhost.sidereal.kz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-interfaces


If bytea can be unlimited size in 7.1, does that mean I can finally
put all my 1gb of MP3s into Postgres, thereby combining all my
favorite stuff?


From: "Gordan Bobic" <gordan(at)freeuk(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Re: Data type for storing images?
Date: 2001-03-13 09:35:59
Message-ID: 000e01c0aba138f5a00010ac@localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-interfaces

More to the point, what would be a reason for not using bytea to
replace BLOBs completely?

----- Original Message -----
From: <drevil(at)sidereal(dot)kz>
To: <pgsql-general(at)postgresql(dot)org>
Sent: Tuesday, March 13, 2001 9:00 AM
Subject: [GENERAL] Re: Data type for storing images?

>
> If bytea can be unlimited size in 7.1, does that mean I can finally
> put all my 1gb of MP3s into Postgres, thereby combining all my
> favorite stuff?
>
>
> ---------------------------(end of
broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>
>


From: "David Wall" <d(dot)wall(at)computer(dot)org>
To: "Gordan Bobic" <gordan(at)freeuk(dot)com>, <pgsql-general(at)postgresql(dot)org>, <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: Re: Data type for storing images?
Date: 2001-03-13 17:06:15
Message-ID: 004701c0abdf$ea24a260a2b7ad8@expertrade.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-interfaces

> More to the point, what would be a reason for not using bytea to
> replace BLOBs completely?

Does anybody know if bytea can be accessed by JDBC yet? I couldn't figure
out how to make it work (setBytes/getBytes) didn't work; only the OID sql
type was working for me with the byte routines.

David


From: "David Wall" <d(dot)wall(at)computer(dot)org>
To: <ryan(at)paymentalliance(dot)net>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Data type for storing images?
Date: 2001-03-13 17:15:42
Message-ID: 012101c0abe1c3a0300a2b7ad8@expertrade.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-interfaces

> I am not sure what your exact purpose is, but in doing a lot of web
> work with pgsql, I usually just store the full path to the image in a
> varchar field and fetch that right into the IMG SRC attribute when I
> need to display the image.

Why would a full path in a IMG tag work? Doesn't your web server use
relative paths based on its document root? If not, you have a serious
security hole allowing people to access any file on your system. <wink>

> I also have modified a simple web based image uploading script so upon
> uploading an image it detects the images width and height and inserts
> that into the DB as well. The script is written in PHP, let me know
> if it would be helpful to send it to you.

I'd be interested in this script. You'll probably need to send it either
"in place" thru the list, or as an attachment directly to me.

Thanks,
David


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Gordan Bobic" <gordan(at)freeuk(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Re: Data type for storing images?
Date: 2001-03-13 18:25:56
Message-ID: 20505.984507956@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general pgsql-interfaces

"Gordan Bobic" <gordan(at)freeuk(dot)com> writes:
> More to the point, what would be a reason for not using bytea to
> replace BLOBs completely?

The fact that encoding/decoding is a pain in the neck :-(. The
lo_read/lo_write interfaces are a relatively convenient way to send
and receive binary data, but the ASCII input-output representation that
bytea uses is not.

We really need some binary-friendly data transmission interface like
lo_read/lo_write for bytea fields before they will be ready to take over
the world. I think Jan has some ideas about how to do that, but it's
not done yet.

regards, tom lane