|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, November 03, 2008 8:55 PM
Points: 1,
Visits: 5
|
|
Would it be the time itself is pretty much an unique value already? So it don't produce a good index on it?
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Tuesday, February 26, 2013 2:11 PM
Points: 108,
Visits: 485
|
|
Sorry Michaell,
I dont understand the question here...
GAJ
Gregory A Jackson MBA, CSM
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Yesterday @ 4:51 PM
Points: 32,923,
Visits: 26,811
|
|
Michaell (3/5/2008) Would it be the time itself is pretty much an unique value already? So it don't produce a good index on it?
Absolutely not... the more unique a value it is, the better an index can be made from it.
--Jeff Moden "RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".
First step towards the paradigm shift of writing Set Based code: Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following... http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Yesterday @ 4:51 PM
Points: 32,923,
Visits: 26,811
|
|
|
|
|
|
SSC-Dedicated
           
Group: General Forum Members
Last Login: Yesterday @ 4:51 PM
Points: 32,923,
Visits: 26,811
|
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Wednesday, August 13, 2008 11:30 PM
Points: 10,
Visits: 23
|
|
Greg,
How can we improve the following query?
------------------------- -------------------------- WHERE filter 1 AND filter 2 AND CONVERT(DATETIME,A.DateValue) BETWEEN (GetDate()-30) AND (GetDate()+30) Column DateValue in table A has datatype (varchar/nvarchar) but datetime.
Thanks in advance.
Rishi
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Wednesday, August 13, 2008 11:30 PM
Points: 10,
Visits: 23
|
|
Many times we need to use function 'MAX' in 'Select' clause specially for dates. Does anyone has a thought on different approach.
For example
select max(a.closedate) as closedate, a.offerid from a inner join b on a.id =b.id inner join c on b.xx = c.xx group by a.offerid
Thanks,
Rishi
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Today @ 3:41 AM
Points: 13,383,
Visits: 25,189
|
|
Rishi Girdhar (3/6/2008)
Many times we need to use function 'MAX' in 'Select' clause specially for dates. Does anyone has a thought on different approach. For example select max(a.closedate) as closedate, a.offerid from a inner join b on a.id =b.id inner join c on b.xx = c.xx group by a.offerid
Thanks, Rishi
We did a series of tests and found, depending on how you do your indexing, TOP actually works a bit better than MAX. You have to include an ORDER BY and get the ASC/DESC right.
---------------------------------------------------- "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt The Scary DBA Author of: SQL Server 2012 Query Performance Tuning SQL Server 2008 Query Performance Tuning Distilled and SQL Server Execution Plans
Product Evangelist for Red Gate Software
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Wednesday, August 13, 2008 11:30 PM
Points: 10,
Visits: 23
|
|
Thanks Grant,
I will try with TOP and ORDER BY and see the difference.
Thanks again, Rishi
|
|
|
|