Re: Storing images in PostgreSQL databases (again)

From: Ron Johnson <ron(dot)l(dot)johnson(at)cox(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Storing images in PostgreSQL databases (again)
Date: 2006-10-06 19:07:37
Message-ID: 4526A979.105@cox.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 10/05/06 18:54, Jean-Christophe Roux wrote:
> Why would I set a bytea column (containing picures) as a primary
> key? Because I want to be sure that the same image is inserted
> only once (that requirement comes from a real project) and using
> a primary key for that purpose makes sense to me.

A hash function makes better sense. SHA-1 creates a 20 byte string
that is the digest of the file. Almost perfect as a primary key.

SHA-256 (so far!) guarantees uniqueness in 32 bytes.

> Am I going to
> retrieve an image row by its image data? I would certainly like!
> For instance, I would like to get the pictures whose main color
> is green (requirement from a real project), and a select * from
> images where main_color(image) = 'green' would be nice.

That would speedily be handled by preprocessing metadata records as
the image is inserted.

- --
Ron Johnson, Jr.
Jefferson LA USA

Is "common sense" really valid?
For example, it is "common sense" to white-power racists that
whites are superior to blacks, and that those with brown skins
are mud people.
However, that "common sense" is obviously wrong.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFFJql5S9HxQb37XmcRAgYjAKCeTur3N/AUwQLI79GYbde8nCMYwACfejg+
Xe3qGl7GHlhC4jssvGkAJ6w=
=dW03
-----END PGP SIGNATURE-----

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2006-10-06 19:16:19 Re: URGENT - startup process (PID 29541) was terminated by signal 6
Previous Message Tom Lane 2006-10-06 19:05:48 Re: DELETE eats up all memory and crashes box