OrchardCMS / Orchard

Orchard is a free, open source, community-focused Content Management System built on the ASP.NET MVC platform.
https://orchardproject.net
BSD 3-Clause "New" or "Revised" License
2.37k stars 1.12k forks source link

Trivial records should not cause trivial database queries #3185

Closed orchardbot closed 9 years ago

orchardbot commented 11 years ago

@bleroy created: https://orchard.codeplex.com/workitem/19356

It's common that records are trivial in that they only have an id, for example when they are just used to represent the end of a n-n relationship. This can result in this kind of entirely unnecessary database query when the Record lazy property is accessed for the first time:

SELECT slideshowp0_.Id AS Id880 FROM SlideShowSlideShowPartRecord slideshowp0 WHERE slideshowp0_.Id = @p0

Another example from a well-known module:

SELECT termspartr0_.Id as Id660 FROM Contrib_TaxonomiesTermsPartRecord termspartr0 WHERE termspartr0_.Id=@p0

We could probably detect that case or provide an attribute telling the framework it's unnecessary to ever query that record by id.

orchardbot commented 11 years ago

@sebastienros closed and commented:

By design. Will be fixed in 2.0.