教你50招提高ASP.NET性能(二十六):对于开发人员的数据库性能技巧

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服务器系统的配置。可是若是你这样作了,这些建议应该能够在使用过程当中帮到你。服务器

  • T-SQL Tips

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小窍门

虽然大部分代码是能够被生成的,可是至少仍是有部分代码不得不手写。若是你正在手动编写一些,若干,或者全部的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:
确保变量和参数都是相同的数据列类型。一个隐式或显示转换会致使表扫描和迟缓的性能。

 

  • Index Tips

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的列时,是有利于加强性能的。老是测试确保索引是有利于性能的。

相关文章
相关标签/搜索