Re: Using bytea field...

From: "David Johnston" <polobo(at)yahoo(dot)com>
To: "'Andre Lopes'" <lopes80andre(at)gmail(dot)com>, "'postgresql Forums'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Using bytea field...
Date: 2011-03-09 01:00:34
Message-ID: 0a2901cbddf5$65518b40$2ff4a1c0$@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 (possibly after encoding) and then comparing the hashes? For a small image it may not matter but if you plan on making the check with any frequency (and multiple times against the same record) doing a one-time hash generation is going to be quite 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 opine on that particular option.

David J.

-----Original Message-----
From: pgsql-general-owner(at)postgresql(dot)org [mailto:pgsql-general-owner(at)postgresql(dot)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 know for example if the file already exists in the database, this is possible with bytea?

Best Regads,

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Reece Hart 2011-03-09 01:06:40 equivalent of mysql's SET type?
Previous Message akp geek 2011-03-08 21:23:42 @@ to_tsquery help