ORM Tips
ORM小窍门

More and more people are using Object to Relational Mapping (ORM) tools to jump the divide between application code that is object oriented and a database that is storing information in a relational manner. These tools are excellent and radically improve development speed. But, there are a few ‘gotchas’ to know about.
越来越多的人正在使用对象关系映射(ORM)作为越过面向对象应用程序代码和关系型存储数据库之间鸿沟的工具。这些工具很优秀从根本上提高了开发速度。但是有一些“陷阱”需要知道。

(42)Avoid following the ‘Hello World’ examples provided with your ORM tool that turns it into an Object to Object Mapping. Database storage is not the same as objects for a reason. You should still have a relational storage design within a relational storage engine such as SQL Server.

招数42:

避免按照你的ORM工具提供的‘Hello World’ 示例以至于把他变成对象到对象的映射。数据库存储和对象存储不一样是有原因的。你应该还有一个在关系型存储引擎比如:SQL Server的设计。

(43)Parameterized queries are exactly the same as stored procedures in terms of performance and memory management. Since most ORM tools can use either stored procedures or parameterized queries, be sure you’re coding to these constructs and not hard-coding values into your T-SQL queries.

招数43:

参数化查询与存储过程在性能和内存管理方面是完全一样的。然而大多数ORM工具可以使用存储过程或参数化查询,确保你根据这些结构进行编码而不要硬编码值到你的T-SQL查询中。

(44)Create, Read, Update, and Delete (CRUD) queries can all be generated from the ORM tool without the need for intervention. But, the Read queries generated are frequently very inefficient. Consider writing a stored procedure for complex Read queries.

招数44:

创建,读取,更新和删除(CRUD)查询都可以通过ORM工具生成不需要干预。但是,生成的读取查询常常是非常低效的。考虑写一个存储过程用于复杂的读取查询。

(45)Since the code generated from the ORM can frequently be ad hoc, ensure that the SQL Server instance has ‘Optimize for Ad Hoc’ enabled. This will store a plan stub in memory the first time a query is passed, rather than storing a full plan. This can help with memory management.

招数45:

由于从ORM生成的代码可以经常被 ad hoc,确保SQL服务器实例已经开启了‘对Ad Hoc优化’。在第一次获得查询后,将在内存中存储一个计划存根,而不是存储一个完整的计划。这样有利于内存管理。

(46)Be sure your code is generating a parameter size equivalent to the data type defined within table in the database. Some ORM tools size the parameter to the size of the value passed. This can lead to serious performance problems.

招数46:

确保你正在生成的代码与数据库中表数据类型定义的参数大小相当。一些ORM工具按照传输值设置参数大小。这可能会导致严重的性能问题。

教你50招提升ASP.NET性能(二十四):ORM小窍门的更多相关文章

  1. 教你50招提升ASP.NET性能(十四):使用startMode属性来减少ASP.NET站点加载时间

    (25)Use the startMode attribute to reduce the load time for your ASP.NET site 招数25: 使用startMode属性来减少 ...

  2. 教你50招提升ASP.NET性能(十六):把问题仍给硬件而不是开发人员

    (27)Throw hardware at the problem, not developers 招数27: 把问题仍给硬件而不是开发人员 As developers, we often want ...

  3. 教你50招提升ASP.NET性能(十九):静态集合

    (30)Static collections 招数30: 静态集合 If a collection is static, make sure it only contains the objects ...

  4. 教你50招提升ASP.NET性能(十八):在处理网站性能问题前,首先验证问题是否出在客户端

    (29)Before tackling any website performance issue, first verify the problem isn’t on the client 招数29 ...

  5. 教你50招提升ASP.NET性能(十五):解决性能问题时不要低估UI的价值

    (26)Don’t underestimate the value of the UI when tackling performance problems 招数26: 解决性能问题时不要低估UI的价 ...

  6. 教你50招提升ASP.NET性能(十):减少通过网络发送的数据

    (16)Reduce the data sent across the network 招数16: 减少通过网络发送的数据 Reducing the amount of data sent acros ...

  7. 教你50招提升ASP.NET性能(十二):在生产环境,仔细考虑你需要记录哪些日志

    (18)When in production, carefully consider what you need to log 招数18: 在生产环境,仔细考虑你需要记录哪些日志 Many peopl ...

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

    Database Performance Tips for Developers对于开发人员的数据库性能技巧 As a developer you may or may not need to go ...

  9. 教你50招提升ASP.NET性能(十一):避免在调试模式下运行网站

    (17)Avoid running sites in debug mode 招数17: 避免在调试模式下运行网站 When it comes to ASP.NET, one of the most c ...

随机推荐

  1. ffmpeg开发指南

    FFmpeg是一个集录制.转换.音/视频编码解码功能为一体的完整的开源解决方案.FFmpeg的开发是基于Linux操作系统,但是可以在大多数操作系统中编译和使用.FFmpeg支持MPEG.DivX.M ...

  2. Darwin Streaming Server用vs2005编译运行过程

    原创. 一:编译 Darwin6.0.3版本是最新版本,也提供了.dsw文件.但是使用vs2005和vc6是编译不过的.所以,采用Darwin5.5.5版本.使用vc6打开WinNTSupport文件 ...

  3. shell中for循环总结

    关于shell中的for循环用法很多,一直想总结一下,今天网上看到上一篇关于for循环用法的总结,感觉很全面,所以就转过来研究研究,嘿嘿... 1. for((i=1;i<=10;i++));d ...

  4. C#的switch与二维数组.....

    今天由于工作上的需要, 改了几行C#  的代码, 发现有一些细微的语法区别,与C++, 像switch语句那样, 我一般不会在default后面加上break,语句, 可是发现如果不加上的话,就会报下 ...

  5. ubuntu1204上不能正常用emacs配合gocode进行自动补全

    我按gocode的页面https://github.com/nsf/gocode上去做,可是还是未成功,,我确认auto-complete在c-mode中是可以使用的,因为有补全出来了, 我再找了ht ...

  6. 【跟我一起学Python吧】Python解释执行原理

    这里的解释执行是相对于编译执行而言的.我们都知道,使用C/C++之类的编译性语言编写的程序,是需要从源文件转换成计算机使用的机器语言,经过链接器链接之后形成了二进制的可执行文件.运行该程序的时候,就可 ...

  7. 基于GPL329xx linux平台电容屏gsl1680的驱动调试分析

    因客户有用到了gsl1680 7寸电容屏,所以拿了一块过来,便在329xx的平台上面开始调试了. 大概浏览了一下所提供的资料,只有介绍模组的资料跟一份中文版的datasheet,datasheet只是 ...

  8. MVC和WebForm的优缺点对比

    1 WebForm优点 1)支持事件模型开发,得益于丰富的服务端组件,WebForm开发可以迅速的搭建Web应用 2)使用方便,入门容易 3)控件丰富的WebForm 2 WebForm缺点  1)封 ...

  9. ACM2050

    问题描述:   平面上有n条折线,问这些折线最多能将平面分割成多少块? 样例输入 1 2 样例输出 2 7 答案是: 2n ( 2n + 1 ) / 2 + 1 - 2n = 2 n^2 – n + ...

  10. Codevs No.1287 矩阵乘法

    2016-06-01 16:53:23 题目链接: 矩阵乘法 (Codevs No.1287) 题目大意: 给你两个可乘矩阵a,b,求a*b 解法: 定义....... //矩阵乘法 (Codevs ...