Good about ORM

  1. Developer is free from building T-Sql on the database tier which is not their major area.
  2. Rapid development
  3. Strongly typed object to ensure data type match with C# type

Page life expectancy

Database data records stored in pages which is 8kb per page, when the data being query, the relevant pages will be load into db memory for futher proccess. and they will stay in the memory until the memory is full and need to clean up the staled pages and make the room for pages required for the new queries.

Cluster indexed scan vs seeking

cluster index *scan* mean reading all data top to bottom cluster index *seeking* is way better than scan cuz it does filter on index so dont filter at client look at client statodtic on client receive bytes from server to understand improvement on byte traffic reduction

explicit join better than nested linq. join is more tsql style. lambda expression is oo better than explicit join.

nested linq explicit join lambda expression

   

code first has the benefit of source agnostic. but choosing the right data type is also impotant for performance.

datatype auto generate by ef raise concern to cost and perf. nvarchar vs varchar. taking up different size of space  given they storing same amount data.

imagine how is that affect and cascade to replica for  HA. BI and bulk load jobs.

also it affects performance as there are extra spaces kept for the same record. remember db engine use page to cache data for plan execution. db type not being evaluated will result in high db memory usage.

data type is critical in a sense that even the same record is stored, with different data type. the record dump to the page can be high as 79m down to 51b (without other changes like adding index) . overstated data type will result in resource dramatically overused.

   

ef offers the capabiloty of altering the datatype and length when exec the code first code to deploy to db. annotation of maxlengh or required can be defined at field level at poco or in a builder context object via fluent API, .IsUniCode mandate the string field map to a varchar rather than nvarchar (for Unicode for cross culture) which is double in size when storing the same data.

lazy loading is like you watching the online movie, you can view the first 10 mins w/o downloading complete clip to get start.

it fit for use when user navigation is uncertained. lamda expression of 'skip' can privide some support. once lazy load is set in ef all reading of the ref table is return null.

eager loading in contrast is aim for the use case that consumer of the data collection having predefine routine to navigate the reference data sets.

ef allows you to add interceptor to change its default crud operation by overwrite e.g. the delete clause to soft delete rather than hard delete.

In summary, 3 type of potential issues need to be considered.

indexing. cluster index, pointer that sorting the teference the table record. non cluster, pointers to the clustered index which itself is sorted. each of them has the overhead and size increase when record inserted or deleted.

when ef cannot performas expected, back to use the good old sp.

IMPLEMENTATION - Entity Framework Anti Pattern - High Performance EF的更多相关文章

  1. 21.翻译系列:Entity Framework 6 Power Tools【EF 6 Code-First系列】

    原文链接:https://www.entityframeworktutorial.net/code-first/entity-framework-power-tools.aspx 大家好,这里就是EF ...

  2. ADO.NET Entity Framework CodeFirst 如何输出日志(EF 5.0)

    ADO.NET Entity Framework CodeFirst 如何输出日志(EF4.3) 用的EFProviderWrappers ,这个组件好久没有更新了,对于SQL执行日志的解决方案的需求 ...

  3. Entity Framework 5.0系列之EF概览

    概述 在开发面向数据的软件时我们常常为了解决业务问题实体.关系和逻辑构建模型而费尽心机,ORM的产生为我们提供了一种优雅的解决方案.ADO.NET Entity Framework是.NET开发中一种 ...

  4. Entity Framework 学习中级篇1—EF支持复杂类型的实现

    本节,将介绍如何手动构造复杂类型(ComplexType)以及复杂类型的简单操作. 通常,复杂类型是指那些由几个简单的类型组合而成的类型.比如:一张Customer表,其中有FristName和Las ...

  5. Entity Framework 5.0系列之EF概览-三种编程方式

    概述 在开发面向数据的软件时我们常常为了解决业务问题实体.关系和逻辑构建模型而费尽心机,ORM的产生为我们提供了一种优雅的解决方案.ADO.NET Entity Framework是.NET开发中一种 ...

  6. Entity Framework入门教程(2)---EF工作流程

    EF工作流程 1.EF基本CRUD流程 下边的图就可以很清晰地展示EF的CRUD操作的基本工作流程: 这里做一个EF CRUD操作的简单总结:1.定义模型:这是EF工作的前提,定义模型包括定义领域类( ...

  7. Entity Framework入门教程(3)---EF中的上下文简介

    1.DbContext(上下文类) 在DbFirst模式中,我们添加一个EDM(Entity Data Model)后会自动生成一个.edmx文件,这个文件中包含一个继承DbContext类的上下文实 ...

  8. Entity Framework入门教程(4)---EF中的实体关系

    这一节将总结EF是怎么管理实体之间的关系.EF与数据库一样支持三种关系类型:①一对一 ,②一对多,③多对多. 下边是一个SchoolDB数据库的实体数据模型,图中包含所有的实体和各个实体间的关系.通过 ...

  9. Entity Framework入门教程(5)---EF中的持久化场景

    EF中的持久性场景 使用EF实现实体持久化(保存)到数据库有两种情况:在线场景和离线场景. 1.在线场景 在线场景中,context是同一个上下文实例(从DbContext派生),检索和保存实体都通过 ...

随机推荐

  1. Django url

    urlpatterns = [ url(正则表达式, views视图函数,参数,别名),]     参数说明:   一个正则表达式字符串 一个可调用对象,通常为一个视图函数或一个指定视图函数路径的字符 ...

  2. VUE框架的初识

    VUE框架的初识 初步了解Vue.js框架(渐进式前端框架) Vue.js是一种轻量级的前端MVVM框架.同时吸收了React(组件化)和Angular(灵活指令页面操作)的优点.是一套构建用户界面的 ...

  3. PuTTY窗口看不到鼠标解决方法

    PuTTY终端工具无法清晰看到鼠标如何处理?通常是因为PuTTY背景色和鼠标颜色相近导致.这里介绍一种通过调整鼠标状态解决方法.说明:文末附PuTTY最新版本下载地址. 操作步骤(Windows10) ...

  4. React-Native: bios打开VT-x选项

    问题: 我在Android Studio新建一个虚拟机的时候出现如图错误: 解决方案:重启电脑,开机的时候不停的按f12(不同的主机不一样),进入bios,然后打开Virtualization Tec ...

  5. 初识Scratch 3.0

    之前在帮朋友搜集少儿编程教育资料的时候,发现了麻省理工开发的积木式编程语言的Scratch,最近有空玩了下,感觉很惊艳,我能想象用它做一些有趣的事情,Scratch把编程元素变成像乐高积木一样,可以通 ...

  6. VS code自定义用户代码片段snippet

    打开VS code,“文件-首选项-用户代码片段-选择新建全局代码片段文件 “ 属性介绍:prefix   就是你自定义的快捷键 body    就是你自定义的代码片段 description 就是这 ...

  7. java课程之团队开发冲刺1.2

    一.总结昨天进度 1.三个任务都已经实现 2.使用时间:四个小时左右 二.遇到的困难 1.对Android原生的侧拉任务栏不了解,导致使用的时候出现了一部分问题 三.今天任务规划 1.对之前的程序重新 ...

  8. del_cursor 批量删除游标

    declare   cursor [del_cursor] is select a.*, a.rowid row_id from [table_name] a order by a.rowid;   ...

  9. excle 内部 超链接(锚点)

    超连接对象: 1.文档 2.本文档中的位置. 3.  本文重点  指定 链接到 xx表中的xx位置. 第三种连接  类似于 web文档的中 锚点 超连接 看下图 选 择本文档中的位置, 选择 工作表. ...

  10. 第五周博客作业 <西北师范大学| 周安伟>

    第五周博客作业 一,助教博客链接https://home.cnblogs.com/u/zaw-315/ 二,本周工作查阅项目汇报,班级微信群.对同学们的中期项目汇报进行查看,解决上周留言问题,对及时出 ...