Sponsor: VoiceMeUp - Corporate & Wholesale VoIP Services

VoIP Mailing List Archives
Mailing list archives for the VoIP community
 SearchSearch 

[Freeswitch-users] mod_lcr and indexes


 
Post new topic   Reply to topic    VoIP Mailing List Archives Forum Index -> freeSWITCH Users
View previous topic :: View next topic  
Author Message
listas at askterisk.com
Guest





PostPosted: Fri Sep 18, 2009 12:09 am    Post subject: [Freeswitch-users] mod_lcr and indexes Reply with quote

Hello all, This is my first message on the list, i´m pretty new to FS. I was playing a bit with mod_lcr and found that the sql query for fetching the lowest rate can be changed to a better use of indexes, at least on mysql. Anyone can do some test using other DBs? The change i've made was simple, the original query was something about "... AND digits IN (12345, 1234, 123, 12, 1) ..." and using EXPLAIN i saw that it was using carrier_id as key for the biggest table and not digits. I've changed the code so the query is " AND (digits='12345' OR digits='1234' OR digits='123' OR digits='12' OR digits='1') " and mysql uses the index from the digits row, reducing the returned resultset of the subquery from all the digits from a carrier to the number of "OR" in the query (in my case, from 19850+ to 14). Anyone think that this may be a nice change? or it is just a bad use of indexes by mysql? Regards, Marcelo Sosa
Back to top
rupa at rupa.com
Guest





PostPosted: Fri Sep 18, 2009 9:13 am    Post subject: [Freeswitch-users] mod_lcr and indexes Reply with quote

Hmm.... This is because mysql is "dumb" Sad Anyway, if you wanted
quoted digits, there is an option to enable that in the mod_lcr config
file.

http://wiki.freeswitch.org/wiki/Mod_lcr#Advanced_Usage

Specifically, look at the parameter: quote_in_list

The most efficient way (that I know of) to use mod_lcr is to use
postgresql and the prefix postgres module which uses a custom datatype
and a GIST index for the prefix column.

On Thu, Sep 17, 2009 at 9:24 PM, Marcelo Sosa - LST
<listas@askterisk.com> wrote:
Quote:
Hello all,

This is my first message on the list, i´m pretty new to FS.
I was playing a bit with mod_lcr and found that the sql query for fetching
the lowest rate can be changed to a better use of indexes, at least on
mysql. Anyone can do some test using other DBs?

The change i've made was simple, the original query was something about "...
AND digits IN (12345, 1234, 123, 12, 1) ..." and using EXPLAIN i saw that it
was using carrier_id as key for the biggest table and not digits. I've
changed the code so the query is " AND (digits='12345' OR digits='1234' OR
digits='123' OR digits='12' OR digits='1') " and mysql uses the index from
the digits row, reducing the returned resultset of the subquery from all the
digits from a carrier to the number of "OR" in the query (in my case, from
19850+ to 14).

Anyone think that this may be a nice change? or it is just a bad use of
indexes by mysql?

Regards,
Marcelo Sosa
_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org





--
-Rupa

_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
Back to top
listas at askterisk.com
Guest





PostPosted: Fri Sep 18, 2009 10:06 am    Post subject: [Freeswitch-users] mod_lcr and indexes Reply with quote

Hello,

I know that mysql is dumb, but i´m postgresql-fobic Smile (i was happy using
pgsql, until i found a bug in the restore of backups, that makes the backup
unable to be restored, very bad day) Smile
Anyway, I was refering to the change from "digits IN (a list of digits)" to
"(digits='xx' OR digits='xxx')", not the quote_in_list option that i found
when i was touching a bit of code.
For the list-archives then, mysql may prefer a different query format to
speed up lcr matches. I´ll test with postgres and check it has any
differences by using one method or another, if not may be we can change the
code so it uses the fastest way for mysql.

Regards,
Marcelo Sosa

----- Original Message -----
From: "Rupa Schomaker" <rupa@rupa.com>
To: <freeswitch-users@lists.freeswitch.org>
Sent: Friday, September 18, 2009 11:07 AM
Subject: Re: [Freeswitch-users] mod_lcr and indexes


Quote:
Hmm.... This is because mysql is "dumb" Sad Anyway, if you wanted
quoted digits, there is an option to enable that in the mod_lcr config
file.

http://wiki.freeswitch.org/wiki/Mod_lcr#Advanced_Usage

Specifically, look at the parameter: quote_in_list

The most efficient way (that I know of) to use mod_lcr is to use
postgresql and the prefix postgres module which uses a custom datatype
and a GIST index for the prefix column.

On Thu, Sep 17, 2009 at 9:24 PM, Marcelo Sosa - LST
<listas@askterisk.com> wrote:
Quote:
Hello all,

This is my first message on the list, i´m pretty new to FS.
I was playing a bit with mod_lcr and found that the sql query for
fetching
the lowest rate can be changed to a better use of indexes, at least on
mysql. Anyone can do some test using other DBs?

The change i've made was simple, the original query was something about
"...
AND digits IN (12345, 1234, 123, 12, 1) ..." and using EXPLAIN i saw that
it
was using carrier_id as key for the biggest table and not digits. I've
changed the code so the query is " AND (digits='12345' OR digits='1234'
OR
digits='123' OR digits='12' OR digits='1') " and mysql uses the index
from
the digits row, reducing the returned resultset of the subquery from all
the
digits from a carrier to the number of "OR" in the query (in my case,
from
19850+ to 14).

Anyone think that this may be a nice change? or it is just a bad use of
indexes by mysql?

Regards,
Marcelo Sosa
_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org





--
-Rupa

_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org




_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
Back to top
rupa at rupa.com
Guest





PostPosted: Fri Sep 18, 2009 10:14 am    Post subject: [Freeswitch-users] mod_lcr and indexes Reply with quote

On Fri, Sep 18, 2009 at 9:47 AM, Marcelo Sosa - LST
<listas@askterisk.com> wrote:
Quote:
Hello,

I know that mysql is dumb, but i´m postgresql-fobic Smile (i was happy using
pgsql, until i found a bug in the restore of backups, that makes the backup
unable to be restored, very bad day) Smile

huh, really?

Quote:
Anyway, I was refering to the change from "digits IN (a list of digits)" to
"(digits='xx' OR digits='xxx')", not the quote_in_list option that i found
when i was touching a bit of code.
For the list-archives then, mysql may prefer a different query format to
speed up lcr matches. I´ll test with postgres and check it has any
differences by using one method or another, if not may be we can change the
code so it uses the fastest way for mysql.

OR list instead of IN list? <sigh/>

What is the size of your rate table? When trying both ways, what is
the measured difference in performance? Does mysql have a way to
analyze the table to ensure it's statistics are up to date?

Quote:

Regards,
Marcelo Sosa

----- Original Message -----
From: "Rupa Schomaker" <rupa@rupa.com>
To: <freeswitch-users@lists.freeswitch.org>
Sent: Friday, September 18, 2009 11:07 AM
Subject: Re: [Freeswitch-users] mod_lcr and indexes


Quote:
Hmm....  This is because mysql is "dumb" Sad  Anyway, if you wanted
quoted digits, there is an option to enable that in the mod_lcr config
file.

http://wiki.freeswitch.org/wiki/Mod_lcr#Advanced_Usage

Specifically, look at the parameter: quote_in_list

The most efficient way (that I know of) to use mod_lcr is to use
postgresql and the prefix postgres module which uses a custom datatype
and a GIST index for the prefix column.

On Thu, Sep 17, 2009 at 9:24 PM, Marcelo Sosa - LST
<listas@askterisk.com> wrote:
Quote:
Hello all,

This is my first message on the list, i´m pretty new to FS.
I was playing a bit with mod_lcr and found that the sql query for
fetching
the lowest rate can be changed to a better use of indexes, at least on
mysql. Anyone can do some test using other DBs?

The change i've made was simple, the original query was something about
"...
AND digits IN (12345, 1234, 123, 12, 1) ..." and using EXPLAIN i saw that
it
was using carrier_id as key for the biggest table and not digits. I've
changed the code so the query is " AND (digits='12345' OR digits='1234'
OR
digits='123' OR digits='12' OR digits='1') " and mysql uses the index
from
the digits row, reducing the returned resultset of the subquery from all
the
digits from a carrier to the number of "OR" in the query (in my case,
from
19850+ to 14).

Anyone think that this may be a nice change? or it is just a bad use of
indexes by mysql?

Regards,
Marcelo Sosa
_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org





--
-Rupa

_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org




_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org




--
-Rupa

_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
Back to top
listas at askterisk.com
Guest





PostPosted: Fri Sep 18, 2009 11:38 am    Post subject: [Freeswitch-users] mod_lcr and indexes Reply with quote

Hello,

Quote:
Quote:
I know that mysql is dumb, but i´m postgresql-fobic Smile (i was happy using
pgsql, until i found a bug in the restore of backups, that makes the
backup
unable to be restored, very bad day) Smile

huh, really?

Bug ID #885 Smile

Quote:
Quote:
Anyway, I was refering to the change from "digits IN (a list of digits)"
to
"(digits='xx' OR digits='xxx')", not the quote_in_list option that i
found
when i was touching a bit of code.
For the list-archives then, mysql may prefer a different query format to
speed up lcr matches. I´ll test with postgres and check it has any
differences by using one method or another, if not may be we can change
the
code so it uses the fastest way for mysql.

OR list instead of IN list? <sigh/>

Yup, kinda weird, isn´t it? IN list should be faster.

Quote:
What is the size of your rate table? When trying both ways, what is
the measured difference in performance? Does mysql have a way to
analyze the table to ensure it's statistics are up to date?

Rate table has about 19k records, i´m just testing. No measured difference
with real calls (haven´t tested it), but mysql has a EXPLAIN command that
analyzes the query and returns information about it (key used, possible
keys, number of rows returned by the subquery, etc).
I´m emailing you by private the EXPLAIN query result, i don´t want to
clobber this list with mysql problems Smile

Regards,
Marcelo Sosa


_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
Back to top
rupa at rupa.com
Guest





PostPosted: Fri Sep 18, 2009 12:46 pm    Post subject: [Freeswitch-users] mod_lcr and indexes Reply with quote

On Fri, Sep 18, 2009 at 11:31 AM, Marcelo Sosa - LST
<listas@askterisk.com> wrote:
Quote:
Hello,

Quote:
Quote:
I know that mysql is dumb, but i´m postgresql-fobic Smile (i was happy using
pgsql, until i found a bug in the restore of backups, that makes the
backup
unable to be restored, very bad day) Smile

huh, really?

Bug ID #885 Smile

What bug repository. Smile

Quote:
Quote:
What is the size of your rate table?  When trying both ways, what is
the measured difference in performance?  Does mysql have a way to
analyze the table to ensure it's statistics are up to date?

Rate table has about 19k records, i´m just testing. No measured difference
with real calls (haven´t tested it), but mysql has a EXPLAIN command that
analyzes the query and returns information about it (key used, possible
keys, number of rows returned by the subquery, etc).
I´m emailing you by private the EXPLAIN query result, i don´t want to
clobber this list with mysql problems Smile

heh, ok, I replied to your email before seeing this. So you can
ignore that part. umm... lets see. We'll keep in private email
until we have an answer an followup here.

At 19,000 records, that is probably just a few blocks on disk -- not
large at all. But we can still try to get this working ok.

Quote:

Regards,
Marcelo Sosa


_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org




--
-Rupa

_______________________________________________
FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
Back to top
Display posts from previous:   
Post new topic   Reply to topic    VoIP Mailing List Archives Forum Index -> freeSWITCH Users All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

VoiceMeUp - Corporate & Wholesale VoIP Services