开发者

many-to-many performance concerns with fluent nhibernate

I have a situation where I have several many-to-many associations. In the upwards of 12 to 15. Reading around I've seen that it's generally believed that many-to-many associations are not 'typical', yet they are the only way I have been able to create the associations appropriate for my case, so I'm not sure how to optimize any further.

Here is my basic scenario.

class Page {
  IList<Tag> Tags { get; set; }
  IList<Modification> Modifications { get; set; }
  IList<Aspect> Aspects { get; set; }
}

This is one of my 'core' classes, and coincidentally one of my core tables. Virtually half of the objects in my code can have an IList<Page>, and some of them have IList<T> where T has its own IList<Page>.

As you can see, from an object oriented standpoint, this is not really a problem. But from a database standpoint this begins to introduce a lot of junction 开发者_如何学Pythontables.

So far it has worked fine for me, but I am wondering if anyone has any ideas on how I could improve on this structure. I've spent a long time thinking and in order to achieve the appropriate level of association required, I cannot think of any way to improve it. The only thing I have come up with is to make intermediate classes for each object that has an IList<Page>, but that doesn't really do anything that the HasManyToMany does not already do except introduce another class. It does not extend the functionality and, from what I can tell, it does not improve performance.

Any thoughts? I am also concerned about Primary Key limits in this scenario. Most everything needs to be able to have these properties, but the Pages cannot be unique to each object, because they are going to be frequently shared and joined between multiple objects.

All relationships are one-sided. (That is, a Page has no knowledge of what owns it). Because of this, I also have no Inverse() mapped HasManyToMany collections.

Also, I have read the similar question : Usage of ORMs like NHibernate when there are many associations - performance concerns

But it really did not answer my concerns.


The question is rather vague.

Why do you assume many-to-many relationships are causing you performance problems? Have you profiled your application?

At a glance, if Modification represents a version or change to a Page, it should be one-to-many, not many-to-many. Maybe you have more of those.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜