Slow query in SQL server when using microseconds -


if run query filters on date, if run exact same query twice, first time my_date_field = '2015-01-01 00:00:00' , second my_date_field = '2015-01-01 00:00:00.000', first 1 (without microseconds) runs faster. normal? i'm using sql server 2008 r2.

some more background, execution plans same when run queries in ssms. i'm not sure if i'd slowness there. see slowness in php application using native sql server driver. noticed slowness because there's loop runs query more once (yeah, know, avoid if possible, hard avoid here) , more records get, more notice slowness. 100 records, process runs fast without microseconds , upwards of 40 seconds them.

update

thanks comments got me digging deeper. changing microseconds mad things faster, it's coincidence. after debugging, discovered absolutely change in way query results in faster query. in, can add space somewhere or remove carriage return , it's fast. guess there's flawed execution plan that's cached somehow. thing has me puzzled query parameters bound, while can see how changing query fix things, i'm surprised changing data date param fixes it. maybe i've got wrong though. problem is, if caches execution plan data, how update execution plan makes sense?

turns out had run sp_updatestats , performance improved quite bit.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

node.js - How to abort query on demand using Neo4j drivers -