Re: Using bytea field... - Mailing list pgsql-general

From David Johnston
Subject Re: Using bytea field...
Date
Msg-id 0a2901cbddf5$65518b40$2ff4a1c0$@yahoo.com
Whole thread Raw
In response to Using bytea field...  (Andre Lopes <lopes80andre@gmail.com>)
Responses Re: Using bytea field...
List pgsql-general
Not sure if it is possible directly but have you considered (or you might have to) generating an MD5 hash of the data
(possiblyafter encoding) and then comparing the hashes?  For a small image it may not matter but if you plan on making
thecheck with any frequency (and multiple times against the same record) doing a one-time hash generation is going to
bequite a bit more efficient. 

Just make sure you know how you are going to keep the hash and the binary contents in-sync.

You could avoid the synchronization issues by putting the hash in an index...in theory...I'd wait for someone else to
opineon that particular option. 

David J.

-----Original Message-----
From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Andre Lopes
Sent: Tuesday, March 08, 2011 1:29 PM
To: postgresql Forums
Subject: [GENERAL] Using bytea field...

Hi,

I'm using a bytea field to store small images in base64. I need to know if I can compare bytea rows for equality. To
knowfor example if the file already exists in the database, this is possible with bytea? 

Best Regads,

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


pgsql-general by date:

Previous
From: akp geek
Date:
Subject: @@ to_tsquery help
Next
From: Reece Hart
Date:
Subject: equivalent of mysql's SET type?