Re: indexes on varchar fields

From: "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk>
To: Peter Nixon <listuser(at)peternixon(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: indexes on varchar fields
Date: 2002-11-08 13:13:28
Message-ID: Pine.LNX.4.21.0211081300200.22364-100000@ponder.fairway2k.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Marc G. Fournier 2002-11-08 13:59:26 PostgreSQL v7.3b5 Packaged for Testing ...
Previous Message Tino Wildenhain 2002-11-08 13:03:17 Re: inet/cidr data types