Re: indexes on varchar fields - Mailing list pgsql-general

From Nigel J. Andrews
Subject Re: indexes on varchar fields
Date
Msg-id Pine.LNX.4.21.0211081300200.22364-100000@ponder.fairway2k.co.uk
Whole thread Raw
In response to Re: indexes on varchar fields  (Peter Nixon <listuser@peternixon.net>)
Responses Re: indexes on varchar fields
List pgsql-general
On Fri, 8 Nov 2002, Peter Nixon wrote:

> On Fri, 8 Nov 2002 12:03:15 +0000 (UTC)
> Squire "Nigel J. Andrews" uttered the following:
>
> Well, they are generated by cisco routers. They are the conference id for
> each voip call and "should" be unique (at least to each router).
> This (41A4DCE3 8CF2D611 85170004 75AE73D4) is the format they come out of
> the router in, and I am just inserting the data directly to a text field.
> You are right, they do seem to be hex numbers. Can postgres accept hex as a
> numberic? if so that would speed things up ALOT...

I'm sure it must be possible but I can't see anything at the moment. So how
about:


create function hex_to_int (text) returns integer as '
    return hex($_[0]);
' language 'plpgsql';

create function int_to_hex (integer) returns text as '
    return sprintf("%X",$_[0]);
' language 'plpgsql';

Used as:

insert int mytable values (hex_to_int('AB456F56'));

and

select int_to_hex(colname) from mytable;

You'd need to be confident that you weren't going to exceed your native integer
size in perl though.


--
Nigel J. Andrews


pgsql-general by date:

Previous
From: Tino Wildenhain
Date:
Subject: Re: inet/cidr data types
Next
From: "Marc G. Fournier"
Date:
Subject: PostgreSQL v7.3b5 Packaged for Testing ...