[asterisk-dev] Realtime behavior questions ...

Jeff LaCoursiere jeff at jeff.net
Tue Aug 18 08:17:14 CDT 2009



On Tue, 18 Aug 2009, Kai Hoerner wrote:

> Tilghman Lesher schrieb:
>>> 1- Same query is performed more than once:
>>> 
>>> For example: the query below regarding the priority "3" from extension
>>> "102" of context "sip" gets performed 3 times... and the same happens
>>> with prior steps(priorities).
>>> 
>>> SELECT * FROM extensions WHERE exten = '102' AND context = 'sip' AND
>>> priority = '3'
>> Yes, that's correct.  It's not optimal, but due to the dialplan 
>> architecture,
>> it's somewhat unavoidable.  A possible optimization would be to cache the
>> results of queries for some short period of time.
> I still can't grasp why a query like this must be performed three (or more) 
> times.
> It will always return the same set of results, if the row was not changed in 
> the meanwhile.
>
> Executing this query more than once for a single lookup is pointless and 
> clearly a waste of resources.

He *did* say it wasn't optimal ;)  The fix is to cache the results, and 
the implementation is left as an exercise for the reader...

j



More information about the asterisk-dev mailing list