Db4O激活深度,Faq,Web应用程序的最佳实践 [英] Db4O activation depth, Faq, Best Practise for Web Application

查看:175
本文介绍了Db4O激活深度,Faq,Web应用程序的最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的数据库包括4,000,000条记录(sql server),它的物理大小为550 MB。
数据库中的实体相互关联为图形样式。当我加载一个实体从db与5级深度有一个问题(所有的记录加载)。

Our database includes 4,000,000 records (sql server) and it's physical size is 550 MB . Entities in database are related each other as graph style. When i load an entity from db with 5 level depth there is a problem (all records are loaded).


  • 是否有任何机制,例如Entity Framework(Include(MyProperty.ItsProperty))

使用db4O数据库的最佳类型是什么?

What is the best Types for using with db4O databases?


  • 任何问题的Guid,通用集合?

  • Is there any issue for Guid, Generic Collections?

有关使用db4o的WebApplication有最佳做法吗?会话容器+ EmbeddedDb4ODb或Client / ServerDb4O?

Is there any best practise for WebApplication with db4o? Session Containers+EmbeddedDb4ODb or Client/ServerDb4O?

Thx for help ..

Thx for help..

Thx有很好的解释。但我想把我的确切的问题作为一个例子:
我有三个实体:(NN关系.B是一个交集实体。概念:图)

Thx for good explanation. But i want to give my exact problem as a sample: I have three entities: (N-N relationship. B is an intersection Entity. Concept:Graph)


class A 
{
 public B[] BList;
 public int Number;
 public R R;
}
class B
{
 public A A;
 public C C;
 public D D;
 public int Number;
}
class C
{
  public B[] BList;
  public E E;
  public F F;
  public int Number; 
}



我想查询dbContext.A.Include(BList.C.BList.A) .Include(BList.CEG)。其中(....)

I want to query dbContext.A.Include("BList.C.BList.A").Include("BList.C.E.G").Where(....)


I want to get           :A.BList.C.BList.A.R
But I dont want to get  :A.R
I want to get           :A.BList.C.E.G
But I dont want to get  :A.BList.C.F
I want to get           :A.BList.C.E.G
But I dont want get     :A.BList.D

注意:可以将查询更改为另一个查询

Note:this requirements can change a query to another query

额外的问题是有可能加载
A.BList [@ Number< 120] .C.BList.A [ @ number> 100]超级语法:)

Extra question is there any possibility to load A.BList[@Number<120].C.BList.A[@Number>100] Super syntax :)

推荐答案

激活:正如你所说db4o使用 activation-mechanism 来控制加载哪些对象。为了防止对许多对象加载,有不同的策略。

Activation: As you said db4o uses it's activation-mechanism to control which objects are loaded. To prevent that to many objects are loaded there are different strategies.


  • 降低全局默认激活深度 configuration.Common。 ActivationDepth = 2 然后使用以下策略激活需要的对象。

  • 使用类特定的激活配置,如级联激活 minimum maximun activation-depth等。

  • 根据需要显式激活对象: container.Activate(theObject,5)

  • Lower the global default activation-depth: configuration.Common.ActivationDepth = 2 Then use the strategies below to activate objects on need.
  • Use class-specific activation configuration like cascading activation, minimum and maximun activation-depth etc.
  • Activate objects explicit on demand: container.Activate(theObject,5)

然而,所有这些东西在复杂的对象图上是相当痛苦的。避免这种痛苦的唯一策略是透明激活。创建一个属性,如TransparentlyActivated。使用此属性标记存储的类。然后使用 db4otool 来增强你的类。添加db4otool命令到Visual Studio中的后构建事件:像'PathTo\Db4oTool.exe -ta -debug -by-attribute:YourNamespace.TransparentlyActivated $(TargetPath)

However all these stuff is rather painful on complex object graphs. The only strategy to get away from that pain is transparent activation. Create an attribute like TransparentlyActivated. Use this attribute to mark your stored classes. Then use the db4otool to enhance your classes. Add the db4otool-command to the Post-Build events in Visual Studio: Like 'PathTo\Db4oTool.exe -ta -debug -by-attribute:YourNamespace.TransparentlyActivated $(TargetPath)

Guid,通用集合:
否(在版本7.12或8.0中)。但是如果你存储你自己的结构:那些由db4o处理非常差。

Guid, Generic Collections: No (in Version 7.12 or 8.0). However if you store your own structs: Those are handled very poorly by db4o

WebApplication:我推荐一个嵌入式容器,然后一个每个请求的会话容器

WebApplication: I recommend an embedded-container, and then a session-container for each request.

更新扩展问题部分

对于这种复杂的激活模式,我将使用透明激活。
我假设你在你的实际场景中使用属性而不是公共字段,否则透明持久性不起作用。

To your case. For such complex activation schema I would use transparent activation. I assume you are using properties and not public fields in your real scenario, otherwise transparent persistence doesn't work.

透明激活基本上加载一个对象一个方法/属性被称为第一个的时刻。所以当你访问属性A.R然后A本身它加载,但不是引用的对象。我只是通过几个你访问模式来显示我的意思:

The transparent activation basically loads an object in the moment a method/property is called the first. So when you access the property A.R then A itself it loaded, but not the referenced objects. I just go through a few of you access patterns to show what I mean:

获取A.BList.C.BList.A.R'

Getting 'A.BList.C.BList.A.R'


  • 当您访问A.BList时会加载A. BList数组用未激活的对象填充

  • 您继续导航到BList.C。此时加载BList对象

  • 然后访问C.BList。 db4o加载C对象

  • 等等。

  • A is loaded when you access A.BList. The BList array is filled with unactivate objects
  • You keep navigating further to BList.C. At this moment the BList object is loaded
  • Then you access C.BList. db4o loads the C-object
  • And so on and so forth.

get'A.BList.C.BList.A.R'then'A.R'is not loaded

So when you get 'A.BList.C.BList.A.R' then 'A.R' isn't loaded

一个卸载的对象由一个' shell对象,其所有值设置为null或默认值。数组总是完全加载,但首先填充了未激活的对象。

A unloaded object is represented by an 'empty'-shell object, which has all values set to null or the default value. Arrays are always fully loaded, but first filled with unactivated objects.

请注意,没有真正的查询语法来做一些精心的加载请求。

Note that theres no real query syntax to do some kind of elaborate load requests. You load your start object and then pull stuff in as you need it.

我还需要提到这种访问将通过db4o在网络上执行可怕。

I also need to mention that this kind of access will perform terrible over the network with db4o.

另一个提示。如果您想对图形结构进行精细的工作,还应该查看图形数据库,如 Neo4J Sones Graph DB

Yet another hint. If you want to do elaborate work on a graph-structure, you also should take a look at graph databases, like Neo4J or Sones Graph DB

这篇关于Db4O激活深度,Faq,Web应用程序的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆