I have a query that I execute from a .NET application to a SQL Server database, and it seems to take quite a long time to complete (5+ minutes). I created a test application in C # to try to see what has been said for so long (the request should return quickly).
Since I restored the query by adding to the elements to see which part takes so long, I ended up restoring the query almost verbatim, where the only difference was the gaps in the original query and the difference in capitalization. This difference returned a result of about 100 milliseconds.
Has anyone seen this before? I am wondering if services are disabled on our server (since a colleague has the same problem) or on our computers.
Thanks in advance for your help.
Example code below (The difference in the first line of the request at the end (fk_source vs. fk _Source):
//Original
OleDbCommand comm = new OleDbCommand("select min(ctc.serial_no) as MIN_INTERVAL from countstypecode ctc, source s, countstype ct, counts c where ct.value_id=c.value_id and s.c_id=ct.fk_source and " +
"ct.timeinterval=ctc.typename and ct.timeinterval in ('15min','1h','1day') and c.time_stamp >= CONVERT(datetime,'01-01-2008',105) and c.time_stamp < " +
"CONVERT(datetime,'01-01-2009',105) and s.c_id = '27038dbb19ed93db011a315297df3b7a'", dbConn);
//Rebuilt
OleDbCommand comm = new OleDbCommand("select min(ctc.serial_no) as MIN_INTERVAL from countstypecode ctc, source s, countstype ct, counts c where ct.value_id=c.value_id and s.c_id=ct.fk_Source and " +
"ct.timeinterval=ctc.typename and ct.timeinterval in ('15min','1h','1day') and c.time_stamp >= CONVERT(datetime,'01-01-2008',105) and c.time_stamp < " +
"CONVERT(datetime,'01-01-2009',105) and s.c_id='27038dbb19ed93db011a315297df3b7a'", dbConn);
source
share