SQL- Performance tuning

Writing SQL Stored Procedures and Views with multiple Table joins  is a very common task and have to ensure that the execution time should be minimal.
There are many possible SQL performance tuning tricks like usng indexer etc..

A very common one I am highlighting here i.e. performance of the SQL Query while using JOIN.

Scenario: You are using joins among multiple tables more than two.
Trick: Try to use the join in such an order that the table which contains the least number of records should come first and then subsequently put the tables with larger records.

SELECT ….
FROM Table1
INNER JOIN Table2 ON ..
INNER JOIN Table3 ON..
INNER JOIN Table4 ON..
Here execution time will be optimum if no. of records in the table are in order TABLE 4> 3> 2> 1, Here also the condition on which we are putting the joins could be a deciding factor.

Posted in SQL

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 )

Connecting to %s