On 09/02/2013 03:57 PM, Pavlo Lavrenenko wrote:
> On 09/02/2013 04:47 PM, Pavlo Lavrenenko wrote:
>> Hi. What I am interested in is the reason of checking both blob contents
>> and its hash. It doesn't seem to be required to compare the hashes
>> and moreover to derive those hashes at all.
>>
>> Please advise.
>>
>
> Oh, its dm_message.c::blob_exists()
It's used to quickly lookup the existence of a blob in the database. The
hash can and is indexed. The blob itself isn't, can't and shouldn't be
indexed.
So:
SELECT id FROM dbmail_mimeparts WHERE hash=<HASH> AND data=<DATA>;
prevents the extremely slow full table-scan used when you just do:
SELECT id FROM dbmail_mimeparts WHERE data=<DATA>;
The reason for also checking the data value is to prevent
hash-collisions, which can and will happen. Google 'birthday attack'
--
________________________________________________________________
Paul J Stevens pjstevns @ gmail, twitter, skype, linkedin
* Premium Hosting Services and Web Application Consultancy *
www.nfg.nl/[email protected]/+31.85.877.99.97
________________________________________________________________
_______________________________________________
Dbmail-dev mailing list
[email protected]
http://mailman.fastxs.nl/cgi-bin/mailman/listinfo/dbmail-dev