Database Performance Tips for Developers
對於開發人員的數據庫性能技巧數據庫
As a developer you may or may not need to go into the database and write queries or design tables and indexes, or help determine configuration of your SQL Server systems. But if you do, these tips should help to make that a more pain free process.緩存
做爲一個開發人員你可能須要進入數據庫編寫查詢和設計表和索引,或者幫助肯定您的SQL服務器系統的配置。可是若是你這樣作了,這些建議應該能夠在使用過程當中幫到你。服務器
While much of your code may be generated, at least some of it will have to be written by hand. If you are writing some, any, or all of your T-SQL code manually, these tips will help you avoid problems.網絡
雖然大部分代碼是能夠被生成的,可是至少仍是有部分代碼不得不手寫。若是你正在手動編寫一些,若干,或者全部的T-SQL代碼,這些提示會幫助你避免問題。app
(47)SELECT * is not necessarily a bad thing, but it’s a good idea to only move the data you really need to move and only when you really need it, in order to avoid network, disk, and memory contention on your server.ide
招數47:性能
SELECT * 不必定是件壞事,可是爲了在服務器上避免網絡,磁盤和內存衝突,只有當你真的須要它時,移動須要的數據,這是一個好主意。測試
(48)For small sets of data that are infrequently updated such as lookup values, build a method of caching them in memory on your application server rather than constantly querying them in the database.ui
招數48:idea
對於更新不頻繁的小數據集,好比:查找值,建立一個方法在應用服務器的內存中緩存他們而不是不斷查詢他們的數據庫。
(49)Ensure your variables and parameters are the same data types as the columns. An implicit or explicit conversion can lead to table scans and slow performance.
招數49:
確保變量和參數都是相同的數據列類型。一個隱式或顯示轉換會致使表掃描和遲緩的性能。
Indexing tables is not an exact science. It requires some trial and error combined with lots of testing to get things just right. Even then, the performance metrics will change over time as you add more and more data.
索引表不是一門精確的科學。它須要一些嘗試和結合錯誤的大量測試。即便那樣,當你添加愈來愈多的數據,性能指標會隨着時間改變。
(50)You get exactly one clustered index on a table.Ensure you have it in the right place. First choice is the most frequently accessed column, which may or may not be the primary key. Second choice is a column that structures the storage in a way that helps performance. This is a must for partitioning data.
招數50:
在一個表上獲得一個徹底正確的彙集索引。確保你把他放在正確的位置。第一選擇是最常常訪問的列,這可能或不能成爲主鍵。第二選擇是一個在某種程度有利於性能的存儲結構列。對於分區數據這是必須的。
(51)Performance is enhanced when indexes are placed on columns used in WHERE, JOIN, ORDER BY, GROUP, and TOP. Always test to ensure that the index does help performance.
招數51:當索引放置在用於WHERE,JOIN,ORDER BY,GROUP,and TOP的列時,是有利於加強性能的。老是測試確保索引是有利於性能的。