2007年5月23日星期三

SQL Performance: Good Practices for Beginners

这里是一篇有更新的SQL性能的一些建议,给初学者。
共有20多条。
http://www.codeproject.com/useritems/SQLGoodPractices.asp
下面摘录前言和前三条。(似乎有些像废话)

Introduction

Most of the developers are like 'accidental developers' and they identify the database performance problems only when the client reports the issues. If you give importants to these guidelines, you can standardise the performance to a stable level. I wrote this article from my own experience and knowledge. Since internet is a wide resource, like most of the professionals I also got such information from the contributions which I read from browsing.

The statements provided here may not be applicable to all the databases since all the features (Eg: Stored Procedures) are not available on all the database systems.

SQL Performance: Good Practices for Beginners

1. Divide your large table to small multiple tables. (In SQL terminology we call it as Normalization)


2. Use the lookup tables. This will help you reduce the overload of tables. Eg: if you have a product-sales table and want to store 3 pictures of the same product, rather than adding three columns to the table use one lookup table. This way you have the freedom to add any number of photos.


3. Also, use only necessary columns. Eg: If you have columns A & B and you have the sum in another column C. Simply, you don't need that C since we can re produce the same table effect with statement SELECT A, B, (A+B) AS C FROM TABLE1.

没有评论: