Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!newsfeed.kamp.net!newsfeed.kamp.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer,comp.programming,comp.lang.java.databases Subject: Re: Storing large strings for future equality checks Date: Wed, 08 Jun 2011 23:20:22 +0200 Lines: 30 Message-ID: <95a7d0Frr9U1@mid.individual.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net RTz7Rn8QYU31gz2Fny7zRAqGWY+iakYIV2wnt7j48SC2D11pE= Cancel-Lock: sha1:YyFMZdNDUVWddD8geWQMntRhu3U= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10 In-Reply-To: Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:5139 comp.programming:448 comp.lang.java.databases:470 On 08.06.2011 18:35, Abu Yahya wrote: > A small application that I'm making requires me to store very long > strings (>1000 characters) in a database. > > I will need to use these strings later to compare for equality to > incoming strings from another application. I will also want to add some > of the incoming strings to the storage, if they meet certain criteria. > > For my application, I get a feeling that storing these strings in my > table will be a waste of space, and will impact performance due to > retrieval and storage times, as well as comparison times. > > I considered using an SHA-512 hash of these strings and storing them in > the database. However, while these will save on storage space, it will > take time to do the hashing before comparing an incoming string. So I'm > still wasting time. (Collisions due to hashing will not be a problem, > since an occasional false positive will not be fatal for my application). > > What would be the best approach? Just out of curiosity: what do those strings represent? What do you do with them? Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/