Re: Unique rows without a key - Mailing list pgsql-general

From Thalis A. Kalfigopoulos
Subject Re: Unique rows without a key
Date
Msg-id Pine.LNX.4.21.0106141110430.19889-100000@aluminum.cs.pitt.edu
Whole thread Raw
In response to Re: Unique rows without a key  (Doug McNaught <doug@wireboard.com>)
Responses Re: Unique rows without a key  (Neil Conway <nconway@klamath.dyndns.org>)
List pgsql-general
On 14 Jun 2001, Doug McNaught wrote:

> "Thalis A. Kalfigopoulos" <thalis@cs.pitt.edu> writes:
>
> > > Thanks for your help. However I was thinking more along the lines of using
> > > the table itself as the index. Creating a hash column with all the other
> > > columns as part of it still significantly increases my table size.
> >
> > It's not that much of an overhead especially if your table has many
> > attributes. There is a function hashname() that will return an
> > integer after hashing the text it takes as argument. I didn't find
> > any documentation, but seems to work.
>
> If it's not documented I'd worry about it going away in the future.
>
> > Then you just add a unique index on hashval and you are done :-)
>
> And if you get a hash collision?  Going to disallow a perfectly
> legitimate and unique row because of it?
>
> -Doug

Right on both points (especially the second one). Is it my imagination or are there plans to add md5 hashing?
Anyway, worst case scenario, one will have to write one's own md5 function and extract the hashval from there. If you
geta collision there, then you should be very happy with your achievement ;-) 

cheers,
thalis


> --
> The rain man gave me two cures; he said jump right in,
> The first was Texas medicine--the second was just railroad gin,
> And like a fool I mixed them, and it strangled up my mind,
> Now people just get uglier, and I got no sense of time...          --Dylan
>


pgsql-general by date:

Previous
From: Lamar Owen
Date:
Subject: Re: Log files, how to rotate properly
Next
From: Olivier Chapiteau
Date:
Subject: stopping execution of a script (on error)