This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
A while ago, in a previous version of LightSpeed, with eager loading OFF for an entity's member collection; when used in a foreach loop, it caused a SQL select for each item in the collection. (As evidenced from an old screencast at http://www.mindscapehq.com/products/lightspeed/screencasts/eager-loading-with-lightspeed). As I recall, when I was working with a previous version Lightspeed, that was indeed the case, a select statement was executed "for each" item in the collection. Now, it appears that the entire collection is retrieved in a single Select statement at the beginning of the "foreach" statement processing. Can you please confirm my understanding that the OLD way was to retrieve each entity with individual select statements, and now, with a more current version of Lightspeed, the NEW way is to perform a single select statement. I just need this clarification before I change the eager load policy for my project. Thanks so much Mindscape gang! ~Bill |
|
|
Hi Bill, No I dont believe there has not been a change to this behaviour, although that video is from LightSpeed 2 days so its been a while! If we are lazy loading a single entity then it will be fetched by Id - in a loop situation you will get N calls to the database. With eager loading you will get a single call inline with the statement which loads the parent entities. If you are loading a child collection then the collection will be fully loaded on first access of the collection (e.g. at the beginning of the first time through the loop). In the video you are seeing a collection load per Product entity, so for each product entity its Sku collection is being fully loaded at the beginning of the inner for loop. This is the same as the current behaviour.
|
|