Tuesday, May 1, 2012

SQL join and optimization experience

I came across my sql join few days ago. The database i created was a temporary one and it is not for a product or something, this just used to store some web  logs that i used for my final year research.

So what i wanna do was join two tables that has about 100 thousand records in both of the tables. But with my simple inner join query it took more than 10 hours but still did not complete.

So i was searching for the ways to increase the performance of the join query and found out that introducing indexes increase the performance in considerable amount of time.

two things i have done was,


  1. Adding primary key constrains 
  2. Adding foreign key constrains 
to my two tables which i have not add previously because this was just temporary tables.

And then the query resulted within 2 minutes for the same number of records.


No comments:

Post a Comment