Re: [GENERAL] Using bytea field...

2011-03-10 Thread Merlin Moncure
On Thu, Mar 10, 2011 at 2:09 AM, Sim Zacks wrote: > >> > The question is, if it screws up and says that an image already exists >> > and then returns a different image when querying for it, how bad would >> > that be. >> > >> >> >> It'll never happen: >> >> >> http://stackoverflow.com/questions/86

Re: [GENERAL] Using bytea field...

2011-03-10 Thread Sim Zacks
> The question is, if it screws up and says that an image already exists > and then returns a different image when querying for it, how bad would > that be. > It'll never happen: http://stackoverflow.com/questions/862346/how-do-i-assess-the-hash-collision-probability Sure you CAN go out of

Re: [GENERAL] Using bytea field...

2011-03-09 Thread Andy Colson
On 03/08/2011 09:06 PM, Andy Colson wrote: On 3/8/2011 12:28 PM, Andre Lopes wrote: 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?

Re: [GENERAL] Using bytea field...

2011-03-09 Thread rsmogura
On Wed, 09 Mar 2011 13:27:16 +0200, Sim Zacks wrote: MD5 is not collision resistant (using the immortal words of wikipedia http://en.wikipedia.org/wiki/MD5). This means that it is possible that multiple images will return the same md5 hash. The question is, if it screws up and says that an imag

Re: [GENERAL] Using bytea field...

2011-03-09 Thread Sim Zacks
On 03/09/2011 01:27 PM, Sim Zacks wrote: This means that it is possible that multiple images will return the same md5 hash. OTOH, if you had an indexed md5 hash and compared the image only to the matches, that would be a fast and accurate querying method -- Sent via pgsql-general mailing list

Re: [GENERAL] Using bytea field...

2011-03-09 Thread Sim Zacks
MD5 is not collision resistant (using the immortal words of wikipedia http://en.wikipedia.org/wiki/MD5). This means that it is possible that multiple images will return the same md5 hash. The question is, if it screws up and says that an image already exists and then returns a different imag

Re: [GENERAL] Using bytea field...

2011-03-08 Thread Josh Kupershmidt
On Tue, Mar 8, 2011 at 8:00 PM, David Johnston wrote: > 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. Yes, a functional index on MD5(your_bytea_column) will work and is the way to go for

Re: [GENERAL] Using bytea field...

2011-03-08 Thread David Johnston
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 t

Re: [GENERAL] Using bytea field...

2011-03-08 Thread Andy Colson
On 3/8/2011 12:28 PM, Andre Lopes wrote: 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, You dont need to use both b