Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
sqlfresher2k7
Aged Yak Warrior
623 Posts |
Posted - 2015-05-04 : 21:30:03
|
I am having performance issue for the below condition and please help me in resolving the issue by rewriting the query to improve the perforomance..there is already non clusterd index created on studentadmissiondate, studentRecorddate but still had performance issues.where ( studentcountrycode = @studentcountrycode ) And ((Studentreportindicator = 1 and studentadmissiondate between @reportstartdate and @reportstartdate) OR (Studentreportindicator = 2 and studentRecorddate between @reportstartdate and @reportstartdate)) Thanks for your help in advance |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2015-05-04 : 21:48:30
|
Show us the execution plan and stats io output. You likely need a better composite index, possibly with include columns. You didn't post the whole query, so it's really hard to help.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
jleitao
Posting Yak Master
100 Posts |
Posted - 2015-05-05 : 06:41:54
|
will not solve your problem but why you have this?studentadmissiondate between @reportstartdate and @reportstartdateyou can replace it by studentadmissiondate = @reportstartdate the same "problem here:studentRecorddate between @reportstartdate and @reportstartdate------------------------PS - Sorry my bad english |
|
|
Kristen
Test
22859 Posts |
Posted - 2015-05-05 : 09:42:33
|
I would use a UNION instead of the OR. 9-times-out-of-10 that fixes slow running queries. |
|
|
|
|
|