How to optimize SQL Join for peformance (speed)

I was working on Joining three table which took 3min 4 sec to execute. Unacceptably slow. There was no way I could make it faster because the logic was straight forward.

Then I though one of the column that I was using in JOIN (even though it was number) did not have index on it. So I put index on it using

create index index_mylastcolumn
on mytable(fieldname)

And then ran my query. It gave result in less than a second.

The result always JOIN on Index column esp if the tables are large!

This entry was posted in Software Development. Bookmark the permalink.

Leave a Reply

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

You are commenting using your 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