eager-loading

DDD performance issue eager loading AR child entities

假如想象 提交于 2019-12-07 00:21:33
In the last days i'm making a sample application to apply/study DDD. One of the principles of DDD(Please correct me if I'm wrong) is that all the changes to an entity should be made through the Aggregate Root(AR) and an AR should be loaded with his child entities. In this way is eaiser to validate Aggregate consistency. There is only a little big detail that is bothering me. I'm not able to understand how DDD is dealing with performance issues. Imagine that i have an Order(AR) that have, let say, 20000, 30000 of OrderLine. Performance issues would exist eager loading a lot of child records.

NHibernate: How to perform eager subselect fetching of many children & grandchildren (object graph) in a single round-trip to the database?

…衆ロ難τιáo~ 提交于 2019-12-06 18:42:47
问题 First, please don't try to argue me out of doing the eager load - traversing the object graph and causing (by lazy loading) even more than ONE round-trip to the database is just not an option. I have a big object graph. I want to fetch the root object, plus a subset of its children, grandchildren, great-grandchildren, etc. Currently I do this by creating multiple Future objects (with Criteria) and in each one, I do SetFetchMode("...", FetchMode.Eager) - see Ayende's post and Sam's 3rd comment

Laravel 4 eager loading and categories, subcategories, articles

房东的猫 提交于 2019-12-06 15:34:18
问题 Hi i thought i can handle this myself, but actually i don't know how to bite it. I am trying to categorise my programs. There will be only 2 levels of categories: 1 CATEGORY 2 |-Subcategory I want it to be as simple as possible. - program can belong to only one subcategory, - categories can have many subcategories, - subcategories can have many programs, Of course i would like to list all programs from subcategories, when someone choose a main category. I am also not sure about my current

Doctrine 2 - Eager loading doesn't appear to work with ManyToMany

China☆狼群 提交于 2019-12-06 14:08:35
I have three entities: SequenceRun has one MaterialTypeString , and has many User . I.e. There is a OneToMany relationship between SequenceRun and MaterialTypeString , and a ManyToMany relationship between SequenceRun and User . SequenceRun.php: /** * @ORM\ManyToOne(targetEntity="MaterialTypeStrings", inversedBy="sequenceRuns") * @ORM\JoinColumn(name="material_type_strings_id", referencedColumnName="id") */ private $materialTypeString; /** * Many Groups have Many Users. * @ORM\ManyToMany(targetEntity="FOSUser", mappedBy="sequenceRuns") */ private $users; Now without eager loading my index

Does GAE Datastore support eager fetching?

孤者浪人 提交于 2019-12-06 13:57:21
Let's say I want to display a list of books and their authors. In traditional database design, I would issue a single query to retrieve rows from the Book table as well as the related Author table, a step known as eager fetching . This is done to avoid the dreaded N+1 select problem : If the Author records were retrieved lazily, my program would have to issue a separate query for each author, possibly as many queries as there are books in the list. Does Google App Engine Datastore provide a similar mechanism, or is the N+1 select problem something that is no longer relevant on this platform? I

Laravel eager loading sort by relationship

我是研究僧i 提交于 2019-12-06 13:03:45
问题 I have some relationships (that i can hopefully explain correctly) and need to sort the output by what is essentially a distant relation. I have a pivot table that contains details for many of the relations, including that that i want to sort by. --User.php public function players() { return $this->belongsToMany('App\Models\Player', 'league_player_user')->withPivot('position_id'); } --Player.php public function position() { return $this->belongsToMany('App\Models\Position', 'league_player

IRepository and Unit Of Work vs Eager Loading

Deadly 提交于 2019-12-06 08:50:35
问题 I know having a Unit Of Work is having an abstraction on top of an abstraction ( DbContext ) and surely that is an anti-pattern, or at least is not necessary. I have the following problem: I have a generic IRepository like so: public interface IGenericRepository<TEntity> where TEntity : class { IEnumerable<TEntity> Get( Expression<Func<TEntity, bool>> filter = null, Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderBy = null, string includeProperties = ""); TEntity GetByID(object id)

Linq-To-Entities Include

偶尔善良 提交于 2019-12-06 08:03:03
问题 I'm currently learning a bit more about Linq-To-Entities - particularly at the moment about eager and lazy loading. proxy.User.Include("Role").First(u => u.UserId == userId) This is supposed to load the User, along with any roles that user has. I have a problem, but I also have a question. It's just a simple model created to learn about L2E I was under the impression that this was designed to make things strongly type - so why do I have to write "Role"? It seems that if I changed the name of

Why doesnt NHibernate eager fetch my data

心不动则不痛 提交于 2019-12-06 07:54:31
I am using Nhibernate for my ORM. I have a class "Control" that has a one to many relationship with ControlDetail (ie. A control has many controlDetails). In the control xml config it has the following <bag name="ControlDetails" lazy="true" access="property" order-by="SortOrder asc" cascade="all-delete-orphan" table="ControlDetail"> <key column="ControlID"/> <one-to-many class="ControlDetail"/> </bag> such that I believe unless otherwise told it would lazy load the controldetails of a control. I am running NHProf to try and fix some performance issues we are having and it has identfied a

Rails 4 Eager load limit subquery

馋奶兔 提交于 2019-12-06 05:27:36
Is there a way to avoid the n+1 problem when eager loading and also applying a limit to the subquery? I want to avoid lots of sql queries like this: Category.all.each do |category| category.posts.limit(10) end But I also want to only get 10 posts per category, so the standard eager loading, which gets all the posts, does not suffice: Category.includes(:posts).all What is the best way to solve this problem? Is N+1 the only way to limit the amount of posts per category? From the Rails docs If you eager load an association with a specified :limit option, it will be ignored, returning all the