Friday, April 3, 2009

Simple Select SQL Tips

Simple Select SQL Tips;
Recently i was trying to optimize my SQL statements to increase the overall performance of the application that im currently working on. I have a friend who is working as a DBA at a reputed company so i decided to get his assitence so that i can reduce some research time.
He was talking about alot of ways to increase performance databases but what i didnt know which he told me was about SQL joins. I always prefer writting joins using aliases rather than using the JOIN/OUTER JOIN keywords. But according what he said when you write join statements using aliases, it is in the end converted to JOIN/OUTER JOIN statement type by the database. So for example if you write an alias join statement as;
Select * from Customer a, Phone b where a.phone_id =;
It is infact converted to the following query by the database;
Select * from Customer INNER JOIN Phone ON;
So you can get better performance by writting your queries in the latter order, yet i still prefer aliases as it is more readable. But then again, the Customer usually doesnt care about code readability but performance. So its a compromise between maintenance vs efficiancy.

No comments:

Post a Comment