Re: longest prefix match - Mailing list pgsql-hackers

From Dimitri Fontaine
Subject Re: longest prefix match
Date
Msg-id 200802201037.43114.dfontaine@hi-media.com
Whole thread Raw
In response to longest prefix match  (Dragan Zubac <zubac@vlayko.tv>)
List pgsql-hackers
Hi,

Le mercredi 20 février 2008, Dragan Zubac a écrit :
> 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 ?

Glad you ask!

I've been taught there are several ways to have a fast longest prefix match
queries working, the best of the possible solutions being to write a
dedicated GiST index support. This is what I've begun doing here: http://pgsql.tapoueh.org/site/html/prefix/index.html
http://pgfoundry.org/projects/prefixhttp://cvs.pgfoundry.org/cgi-bin/cvsweb.cgi/prefix/prefix/ 

This should work ok with 8.2 or 8.3 (I don't intend to support older releases
atm). The current code will allow you to create an index and use it in your
queries, as stated on the README.txt: CREATE INDEX idx_prefix ON prefixes USING GIST(prefix gist_prefix_ops); SELECT *
FROMprefixes WHERE prefix @> '0218751234'; 

But it seems (from some comments I've got on IRC) that current implementation
performances are much less than one would expect from indexing support, so
we're about to implement some prefix-range datatype in order to come up with
a better picksplit(). I hope to have some time again to share on this project
pretty soon.

Regards,
--
dim

pgsql-hackers by date:

Previous
From: "Dawid Kuroczko"
Date:
Subject: Re: Permanent settings
Next
From: Dimitri Fontaine
Date:
Subject: Re: Permanent settings