Indexing your MS SQL Database to improve performance

Hello again!  It’s been a long time since my last publication, but its better late than never.  My topic today is how to improve database performance to make your application efficient.  To be specific, we would be talking about database indexing.

Normally we rely on the Primary Keys as the default index of the table. But in most of our queries we are using other fields which are not Primary Keys, thus resulting to performance issues if we are dealing with large data-sets and codes that contains lambda expressions in a LINQ statement similar to the code below:

Id = cloudDB.CloudMstSymbols.Where(d=>d.Symbol==Price.Symbol).First().Id;

It’s easy to make an index using the SQL Management Studio.  Just right click on the table that you wish to add an index and go to design, click the index icon then add and index using the dialog box provided.  (see image below)

b11

If you can’t use the management studio, e.g., your database resides in the cloud (Windows Azure), you can use Visual Studio and write down the SQL statement similar to the one below:

CREATE NONCLUSTERED INDEX [IX_MstSymbol_Symbol]
    ON [dbo].[MstSymbol]([Symbol] ASC);

That’s it.  Happy coding and if you find this blog helpful, you can make the donation by clicking the Paypal button below.


Advertisements

One thought on “Indexing your MS SQL Database to improve performance

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s