简体   繁体   English

Telerik DataAccess(OpenAccess)可为空的外键性能

[英]Telerik DataAccess (OpenAccess) nullable foreign key performance

We are looking for help from people who use Telerik DataAccess ORM. 我们正在寻找使用Telerik DataAccess ORM的人员的帮助。 Recently, we encountered a big performance issue with nullable foreign key. 最近,我们遇到了一个可空外键的大性能问题。

When we assign value to nullable int foreign key property (without SaveChanges) - Telerik makes several calls to the database and do some strange work. 当我们为可为空的int外键属性分配值时(没有SaveChanges)-Telerik对数据库进行了多次调用,并做了一些奇怪的工作。 We used dotTrace and found that there are a lot of SQL DataReader calls and some strange string/DateTime/Enum/... converters. 我们使用dotTrace并发现有很多SQL DataReader调用和一些奇怪的string / DateTime / Enum / ...转换器。 This issue only appears when we set value to the property, get is working ok. 仅当我们将属性设置为value时,才会出现此问题,get正常工作。

A little bit about our environment. 关于我们的环境的一点点。 We tried to create an empty console app. 我们试图创建一个空的控制台应用程序。 The same strange code is invoked, but it is much faster in local environment - ~60ms for small Entity and local db. 调用了相同的奇怪代码,但是在本地环境中它要快得多-对于小型Entity和本地db,约为60ms。 For big entity it is ~ 1.5 sec, but in our production server that uses Azure Sql DB - it is from 10 to 50 second . 对于大型实体,这是〜1.5秒, 但是在使用Azure Sql DB的生产服务器中,这是10到50秒

Remark: we tried to load and set object directly, without using foreign key, it does not help. 备注:我们尝试不使用外键直接加载和设置对象,这没有帮助。

public class Entity
{
    public int? ParentId { get; set; } // Wee see this issue when we set value to the ParentId or Parent property. SaveChanges is not called.

    public Parent Parent { get; set; }
}

Here you can find the dotTrace call stack. 在这里您可以找到dotTrace调用堆栈。

Finally, I solved this issue. 最后,我解决了这个问题。 I want to warn everyone who uses IsManaged configuration. 我想警告所有使用IsManaged配置的人。 Every time when you set ParentId or Parent entity, ALL children with specified ParentId are loaded into memory. 每次您设置ParentId或Parent实体时,所有具有指定ParentId的子级都会加载到内存中。 Even if lazy-load is enabled. 即使启用了延迟加载。

Telerik agree that this behavior can be optimized, but they don't want to make any changes because of backward compatibility. Telerik同意可以优化此行为,但是由于向后兼容,他们不希望进行任何更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM