Re: Hash Function: MD5 or other?

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Peter Fein <pfein(at)pobox(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Hash Function: MD5 or other?
Date: 2005-06-14 21:27:30
Message-ID: 20050614212730.GA27141@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Jun 14, 2005 at 15:54:50 -0500,
Peter Fein <pfein(at)pobox(dot)com> wrote:
>
> I'm unclear why I'd need to store the hash in a column. I suppose I
> could have the hash column populated by a trigger on inserts, but this
> seems to get me the same functionality & is less obvious.
>
> For the archives, I did:
>
> CREATE UNIQUE INDEX idx_md5_sometext ON mytable USING btree
> (group_id, md5(sometext))
> WHERE group_representative = true;
>
> I then basically replicate this in a SELECT on the client side
> (including calculating the MD5 by the client) to figure out the correct
> value for group_representative before inserting a new row. This is the
> only way I use the MD5, so I don't much care about retrieving it in
> other contexts.

That should work fine.

I wasn't sure that you weren't going to want to use the hash for joins.
And I was a little concerned that because you used the phrase "hash index",
that you might be considering using a hash (as opposed to btree) index.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Zlatko Matić 2005-06-14 22:17:55 user groups
Previous Message Peter Fein 2005-06-14 20:54:50 Re: Hash Function: MD5 or other?