Large DDI range 10k> dialplan config

Hi I am about to implement a large DDI range of 10k> numbers.

In the past I have created sip trunks in sip.conf which sends the call to a context in extensions.conf

Typically I would then list all of the matching numbers to an extension which calls a macro (or sub routine) to direct the call to where it needs to go.

With 10k> numbers I am wondering if adding 10k lines to extensions.conf is a good idea from a performance perspective.

Would it be better to store the numbers in a database and call them from there. Certainly it would be easier to manage and making changes wont require a reload of asterisk but is this what large providers do or do they do something else?

Any comments or advice on how to manage large number ranges would be appreciated


Unless its a concurrent range going to a matching concurrent range
ie 02031210000 - 02031219999 to ex [1-9]0000 - [1-9]9999 then a external DB is the best and answer

Yes it would be a contiguous range and thus would add 10K lines to my extensions.conf.

What impact to asterisk performance would there be by adding this many lines of code or is there a performance increase by off loading this to a database perhaps on a separate server?

From a user perspective perhaps there is a performance increase by having the config in memory rather than access the data from a database.


If it’s a contiguous range of 10,000 numbers rather than add 10,000 entries I would just use a pattern match (see … n+Matching) if you want to route each number in the same way, or split them into blocks of 100-1000.

If you need to do something different with each of the 10,000 numbers, I would use a pattern match and a database look-up. You could pass ${EXTEN} into an AGI script, do a lookup and return a variable;

… php code to query a db …
$agi->set_variable(numberToDial, $myLookup);

And then do the dial on the next line of the dialplan;

same => 10,Dial(SIP/${numberToDial}

If you have an index on the DB table and write the AGI script efficiently, the lookup will be very very quick and there wouldn’t be much of a delay.

as said if its a direct correlation then

exten => _0203123XXXX,1,Noop(New call from ${CALLERID(all) to ${EXTEN}
exten => _0203123XXXX,n,Dial(SIP/${EXTEN:6},)
exten => _0203123XXXX,n,VoiceMail(${EXTEN:6})

will work at its absolute simplist

Yes I think I should do this with a database. The more I think about what I have to deliver the more sense it makes.

But I’m missing a step I think.

Currently all calls come in from one provider which is listed in sip.conf
The configuration in sip.conf points to a context which for this purpose I could call "inbound"
I’m guessing I need to do a pattern match like {exten => _X.,1,Macro(inbound)} to point all incoming calls to a macro
The macro would take the incoming number and perform a lookup using a set command and a query in func_odbc.conf
next step to use array to get the returned options back into dialplan
and finally send it off to the appropriate macro defined in the database with its various variables.

Does this sound right or is there a more elegant way?