[Asterisk-Users] OT : For the SQL gurus..

WipeOut wipe_out at onetel.com
Mon Nov 10 12:07:36 MST 2003


Thanks everyone for your help on this..

For those who are interested I have done some speed tests on these two 
queries (below) on my server and the results are..

Test script of 1000 quieries..
Query1 ("code" field not indexed) = 47.183s
Query1 ("code" field indexed) = 45.731s
Query2 ("code" field not indexed) = 109.321s
Query2 ("code" field indexed) = 2.302s

Query2 has additional overhead in the script as well because it has to 
itterate through the number and build up the query..

Query1 is far simpler to use in a script becasue the query does not have 
to be built up..

Query1
======
SELECT *, LENGTH(code)
FROM a
WHERE code = left('00442085673456', LENGTH(code))
ORDER BY LENGTH(code) DESC LIMIT 1;

Query2
======
SELECT *, length(code)
FROM a
WHERE code = '00442085673456'
OR code = '0044208567345'
OR code = '004420856734'
OR code = '00442085673'
OR code = '0044208567'
OR code = '004420856'
OR code = '00442085'
OR code = '0044208'
OR code = '004420'
OR code = '00442'
OR code = '0044'
ORDER BY length(code) DESC;






More information about the asterisk-users mailing list