Re: digest data types?

From: Reece Hart <reece(at)harts(dot)net>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: SF PostgreSQL <sfpug(at)postgresql(dot)org>
Subject: Re: digest data types?
Date: 2007-04-12 23:34:35
Message-ID: 1176420875.4806.83.camel@snafu.site
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: sfpug

Neil-

Thanks for the reply.

On Thu, 2007-04-12 at 18:56 -0400, Neil Conway wrote:
> In most cases, I don't think this would have a significant performance
> impact.

So, why is that? Admittedly, I haven't looked at the postgresql indexing
code, but I assume at least for btree and hash that the values are the
majority of the index mass for anything but trivial keys. So, my
reasoning was that 2x storage of the underlying type leads to ~2x index
sizes and potentially 2x more IO. I take it from your reply that I'm
misthinking this.

I've been toying with writing a custom type. I started off writing,
essentially,
typedef struct {
unsigned digest_len;
void* digest_binary;
} digest;

As I was implementing the digest_in and digest_out functions (using
hex_encode/hex_decode ripped off from src/backends/utils/adt/encode.c),
it occurred to me that I'll then need to declare this type
INTERNALLENGTH=VARIABLE, which then tacks on VARHDRSZ. And then I
realized that I really didn't know the performance consequences of
variable length values versus fixed length values. Clearly, I'm a
beginner here. Essentially, what I'm asking is: does it make more sense
to have a single type (eg, digest), or several size-specific types (eg,
digest128, digest160, digest224, etc).

Comments?

Of course, *if* I do this, I'd like to do so in a kosher way that would
enable it to get rolled into the mainline (pg_crypto?).

-Reece

--
Reece Hart, http://harts.net/reece/, GPG:0x25EC91A0

In response to

Responses

Browse sfpug by date

  From Date Subject
Next Message Steve Atkins 2007-04-12 23:42:26 Re: digest data types?
Previous Message Neil Conway 2007-04-12 22:56:00 Re: digest data types?