we have a procedure here with a cursor to access a table with about 115000 rows in it ... the table is a list of links, and works quickly if written without ambiguity. However the way we need to run it means that up to 2 parameters can be entered, and the more parameters entered the greater the discrimination ... and if no parameters are entered then it shows all possible matches (such that they are)
the code is roughly as follows:
where Selected_Technique and Selected_Matrix are passed in variables to the procedure.
Matrix, Technique and Testname are tables with text strings in them, and expanded_tests is a lookup table that joins them together.
the weak point is :
or the Selected_Matrix equivalent, where there is an 'or' statement, so for each row of the table it seems to recheck the Selected_Technique against null ...
if i remove the 'or' and specify the variables then it takes a fraction of a second. if i leave them it takes about 10 seconds.
is there any way of doing this within an sql cursor such that it either only checks once, or a replacement that does the same job?
Thanks
Jon
the code is roughly as follows:
Code:
cursor c_curs is
select testnames.short_test_name, Matrix.matrix_name,
TECHNIQUEs.short_TECHNIQUE_name
from expanded_tests, techniques, matrix, testnames
where ( Selected_Technique is Null
or techniques.Techniqueid = Selected_Technique)
and ( Selected_Matrix is Null
or matrix.matrix_id = Selected_Matrix)
and techniques.techniqueid = expanded_tests.TECHNIQUE_TECHNIQUEID
and matrix.matrix_id = expanded_tests.MATRIX_MATRIX_ID
and testnames.testname_id = expanded_tests.TESTNAME_TESTNAME_ID
and expanded_tests.show = 1
order by upper(TECHNIQUEs.short_TECHNIQUE_name),
upper(Matrix.matrix_name),
upper(testnames.short_test_name);
where Selected_Technique and Selected_Matrix are passed in variables to the procedure.
Matrix, Technique and Testname are tables with text strings in them, and expanded_tests is a lookup table that joins them together.
the weak point is :
Code:
where ( Selected_Technique is Null
or techniques.Techniqueid = Selected_Technique)
if i remove the 'or' and specify the variables then it takes a fraction of a second. if i leave them it takes about 10 seconds.
is there any way of doing this within an sql cursor such that it either only checks once, or a replacement that does the same job?
Thanks
Jon