Speed Up your SQL Queries with These Tips & Tricks

Posted by Brad Trevaskis on October 20, 2017


The Crestwood Development staff had a recent team sharing session.  One of the things they went over were some great tips and tricks for SQL that we thought you might enjoy too.

Index-Friendly Operators

If you have indexes in your databases, using index-friendly operators can speed up searching.  Indexes identify what data we really care about in a table, so it looks there first.  If you don’t have indexes, then it has to do an entire table scan.  When using operators to find data, basically, anything that is equality is good to use and will give you quick search results.

 

Set NoCount On

Another way to speed up queries is to turn off the row counting feature.  If you set the NoCount to On, then it doesn’t require us to keep counts of the rows returned and output them.  So, make sure to SET NOCOUNT ON to disable these messages.

Text Selection

We don’t recommend writing insert statements directly, that’s when we use other tools like integration services.  However, if you are, here’s a time saving tip.

  • Select multiple whole rows
  • Then use Alt+Select to enter code on multiple lines at once

Scrollbar Tricks

In SQL Server Management Studio 2016+, there is a checkbox option to turn on a handy little preview area on the right, called Map Mode.  Additionally, we find it helpful to use a split window too.  That way you can view two sections of the same document at once.

Want more tips like these? Subscribe to our blog and get updates delivered right to your inbox.


Share this:
 
 

Comments:

Add your comment: