<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>

<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"\@MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>In our testing with SQL Server, we found that executing several
queries for direct matches yielded far better performance than one query trying
to check prefixes. (The column was also part of the clustered index, but AFAIK
MySQL doesn&#8217;t support defining your own clustered indexes; you get the PK
always.)<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>-Michael<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> freeswitch-users-bounces@lists.freeswitch.org
[mailto:freeswitch-users-bounces@lists.freeswitch.org] <b>On Behalf Of </b>Diego
Viola<br>
<b>Sent:</b> Tuesday, October 13, 2009 7:54 PM<br>
<b>To:</b> freeswitch-users@lists.freeswitch.org<br>
<b>Subject:</b> Re: [Freeswitch-users] Some help with my post-paid billing
project<o:p></o:p></span></p>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal style='margin-bottom:12.0pt'>Wrong question.<br>
<br>
Is there a way to compare numbers with prefixes without using the prefix
module?<br>
<br>
Diego<o:p></o:p></p>

<div>

<p class=MsoNormal>On Wed, Oct 14, 2009 at 1:36 AM, Diego Viola &lt;<a
href="mailto:diego.viola@gmail.com">diego.viola@gmail.com</a>&gt; wrote:<o:p></o:p></p>

<p class=MsoNormal>I'm using MySQL now but I will try PostgreSQL with the
prefix module, is there a way to do that without the prefix module and with
regular SQL?<br>
<br>
Any examples?<br>
<span style='color:#888888'><br>
Diego</span><o:p></o:p></p>

<div>

<div>

<p class=MsoNormal style='margin-bottom:12.0pt'><o:p>&nbsp;</o:p></p>

<div>

<p class=MsoNormal>On Tue, Oct 13, 2009 at 10:45 PM, Even André Fiskvik &lt;<a
href="mailto:grevenx@me.com" target="_blank">grevenx@me.com</a>&gt; wrote:<o:p></o:p></p>

<p class=MsoNormal>What database are you using?<br>
You could do this with regular SQL, but it would by a costly operation,<br>
for PostgreSQL we're using the prefix module: <a
href="http://pgfoundry.org/projects/prefix/" target="_blank">http://pgfoundry.org/projects/prefix/</a><br>
<br>
You can then match the closest prefix by using something like<br>
&quot;WHERE myprefix_col @&gt; caller_destination_number ORDER BY LENGTH<br>
(myprefix_col::text) LIMIT 1;&quot;<br>
<br>
<br>
Best regards,<br>
Even André<o:p></o:p></p>

<div>

<div>

<p class=MsoNormal><br>
<br>
On 13. okt. 2009, at 23.53, Diego Viola wrote:<br>
<br>
&gt; Hello,<br>
&gt;<br>
&gt; I'm trying to write a post-paid billing script, I have the CDR on my<br>
&gt; database and also a &quot;rates&quot; table, the CDR contains fields like<br>
&gt; caller_destination_number, variable_duration, etc. and the rates<br>
&gt; table contains: destination, prefix, rate (cost).<br>
&gt;<br>
&gt; The problem is that I can't just strip the destination number to<br>
&gt; take the prefix from it because I have to deal with destination<br>
&gt; numbers from different countries and they all have different prefix<br>
&gt; lengths... so I need to find another way to take the prefix from the<br>
&gt; destination number.<br>
&gt;<br>
&gt; Any ideas how to do this?<br>
&gt;<br>
&gt; Thanks,<br>
&gt;<br>
&gt; Diego<br>
&gt;<o:p></o:p></p>

</div>

</div>

<p class=MsoNormal>&gt; _______________________________________________<br>
&gt; FreeSWITCH-users mailing list<br>
&gt; <a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
&gt; <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users"
target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
&gt; UNSUBSCRIBE:<a
href="http://lists.freeswitch.org/mailman/options/freeswitch-" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-</a><br>
&gt; users<br>
&gt; <a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
<br>
<br>
_______________________________________________<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users"
target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a
href="http://lists.freeswitch.org/mailman/options/freeswitch-users"
target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><o:p></o:p></p>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

</div>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

</body>

</html>