no, in order to find the best match we do a manual trick
using the s.prefixes transformation (I think you suggested
that).
could be, at least is the way I do prefix matching with mysql.
Postgres, on the other hand, afaik, has an index plugin to match the
longest prefix, might not be in default distro, but can be found on
the net for sure.
We start with the full $rU and stop when we find a non-null
value. This kamailio is serving many thousands of calls per
hour, and the response time is pretty much the same as when we
used the mtree module. For us , using redis has the advantage of
being able to load the tree data faster than when we used
postgres without the need to perform a mtree reload.
Loading huge amount of records from mysql takes time indeed.
Maybe prefix matching will be added in redis in the future, or
scripted server side in lua, as I understood it has such feature.
Another option would be to add a custom command in kamailio like
redis_cmd_pmatch() to do internally these prefix-based commands
until a match, could simplify the config if it becomes something
very popular.
Just mentioning it here for let it be known, if redis is working
fine for you, makes no sense to look for other solutions.
Cheers,
Daniel
Regards
Javi
On Fri, Feb 17, 2012 at 10:25 AM,
Daniel-Constantin Mierla <miconda@gmail.com>
wrote:
Hello Javier,
one question about redis, can it do longest prefix
matching or all prefixes match?
Cheers,
Daniel
On 2/16/12 2:51 PM, Javier Gallart wrote:
Hello Uri
I had similar needs and I found the ndb_redis
module more suited for that type of task. Instead
of a tree you have a hash like this: tname tprefix
tvalue. If you do a hget nts $avp(DID) and
you get a not null value you have found your
exact match. It works very well for me and the
time it takes for that "query" is barely
noticeable. Of course redis does not address
items like persistence, etc the same way a rdbms
does.
Message: 1
Date: Thu, 16 Feb 2012 12:54:50 +0200
From: Uri Shacked <ushacked@gmail.com>
Subject: [SR-Users] how to match exact string
value in mtree
To: "SIP Router - Kamailio (OpenSER) and SIP
Express Router (SER) -
Users Mailing List" <sr-users@lists.sip-router.org>
Message-ID:
<CAMMbDhTFNXAE-K88=AeMjO7AnA_QJV3Ajj3AH-AxemXN3ze6HQ@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Hi,
I am using Mtree to match prefix numbers, some
of them starts with 0 or
characters like D for example.
so, the mtree param is like this: