java - Specific Query runs fine directly or when any change to it is made but in current state takes longer to run -
major update after couple days of debugging:
i run few queries similar :
select rtrim(part) part tablep pm left join tables s on pm.id = s.id inner join tablec cm on cm.id = pm.id name = 'ngw' , status not in ('nl', 'z') group rtrim(part), isnull(s.value,0) order isnull(s.value,0)
it run in java so:
preparedstatement select = con.preparestatement( "select rtrim(part) part" + "from tablep pm " + "left join tables s on pm.id= s.id " + "inner join tablec cm on cm.id= pm.id " + "where name =? , status not in ('nl', 'z') " + "group rtrim(part), isnull(s.value,0) " + "order isnull(s.value,0) " ); select.setstring(1, name); resultset rs = select.executequery(); while(rs.next()){ ... data loaded...
the queries have been running fine inside of java application. 3 or 4 queries of form went taking less second on minute.
i have copied exact query sql profiler , when run directly on database preforms in less second. started make changes query , found change query return 1 second performance even adding single space between statement. returned original exact state take 60+ seconds.
core question: so, have fix, cause query run differently change small whitespace?
is possible execution plan corrupted? can try explicitly clearing plan cache? http://msdn.microsoft.com/en-us/library/aa175244(v=sql.80).aspx
Comments
Post a Comment