Re: longest prefix match

From: Jorge Godoy <jgodoy(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: longest prefix match
Date: 2008-02-20 11:25:48
Message-ID: 200802200825.49084.jgodoy@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Em Wednesday 20 February 2008 05:55:07 Dragan Zubac escreveu:
>
> Anybody got any ideas/experiences/links for 'longest prefix match'
> solution in PostgreSQL ?
> Basically,put some telephone prefices in some kind of trie,and be able
> to perform fast lookups ?

Prefix or suffix?

For prefix you can use "SELECT number FROM table WHERE number LIKE '123%'".

For suffix you change the "%" to the beginning of the string, but then loose
the ability to use indices. (Unfortunately, using suffixes is really
interesting for caller IDs since you don't always receive area code, country
code, etc.)

--
Jorge Godoy <jgodoy(at)gmail(dot)com>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Oleg Bartunov 2008-02-20 12:00:22 Re: longest prefix match
Previous Message Jorge Godoy 2008-02-20 11:21:21 Re:

Browse pgsql-hackers by date

  From Date Subject
Next Message Gregory Stark 2008-02-20 11:30:17 Re: failed assertion in toasting code
Previous Message Teodor Sigaev 2008-02-20 11:06:00 Re: failed assertion in toasting code