Reputation: 35268
I am asking this question in stackoverflow because its the right place to ask...
I know its a very vast topic to start but some small ones which may be really handy...
It might be useful for young developers like me to know about query optimization..
Some Tips and Tricks about query optimization in SQL Server 2005..
Upvotes: 7
Views: 2566
Reputation: 207863
For queries I can add to gbn
, recursive
and smaclell
the followings:
INSERT
and DELETE
queries in transactionsUPDATE
is slower for multiple records than just inserting them again. So advised is to SELECT, DELETE, than programmatically update the records and re-INSERT with the existing keys (watch out for CASCADE
and TRIGGERS
)Upvotes: 1
Reputation: 4658
Upvotes: 1
Reputation: 432210
Based on questions here
eg
...WHERE tinyintcol = @intvalue
means a conversion of the column and invalidates an index
...WHERE tinyintcol = @tinyintvalue
eg
...WHERE DATEADD(day, 1, MyCol) > GETDATE()
should be
...WHERE MyCol > DATEADD(day, -1, GETDATE())
Covering indexes
GUIDs: not clustered indexes
Upvotes: 2
Reputation: 86064
The most obvious place to start if you have a slow query is to make sure it's using an index.
Upvotes: 1