Jon Earle <je_pgsql@kronos.honk.org> writes:
> Is there a way to, when I add a record to a table, have the md5 hash
> computed and stored in the same table and then returned to the calling
> program? Currently, I'm using the perl md5 function to compute the hash
> and store it in the DB but I'm thinking that offloading this to the DB
> itself might be faster (of course, if that's not true and the way I'm
> doing things now is fine, then I'll leave it as it is).
If your webserver is heavily loaded and the DB server isn't too busy,
this might be a win; otherwise it's unlikely to make any difference.
I think perl calls out to C to do the md5 computation, so it's just as
fast as the version in Postgres.
That said, the way to do it if you wanted to would be to write an
insert_my_record() function that stores the data for the record and
returns the md5 hash.
-Doug