locked
How to load properties of a object on the "performance" way RRS feed

  • Question

  • Hi,

    I have the follow problem:

    In the ContentType table there are templates of Contents. A ContentType is a template of a "Webpage" (Let say a: newsitem template, or a regulair webpage template, etc ...).

    ContentType
    ContentTypeId
    Name
    ...

    Content
    ContentId
    ContentTypeId
    Name
    Title
    ...

    ContentProperties
    ContentTypeId
    Name
    ...

    ContentValues
    ContentPropertyId
    ContentId
    Value
    ...

    When we have 50 ContentTypes with 15 properties each and a round 100 webpages its not the best performance. Is there a better way to do this?

    Also when we load all Content then we also want to preload the properties with values but thats also a performance issue.
    For example if we have 100 Contents (webpages) then we need to request the database for like 101 times.
    1 request for all the Contents
    100 request for all the properties of each Content.

    Is there also a better way to do this?

    Kind Regards,

    Flaminio

     

    Wednesday, October 5, 2011 9:43 AM

All replies

  • You could try implementing the Lazy Load pattern. Using this pattern, data isn't loaded when the object is created. Rather, data is loaded when the property is accessed. The object "knows" how to get data from the data store when a property is accessed. Pseudo-code would look something like:

     

    public class Content 
    {
        private string _name;
    
        public string Name
        {
            get
            {
                if (_name == null)
                {
                     // get data from db
    
                     // assign data to _name
                }
            }
        }
    }
    

    Using lazy loading can increase performance since the db is only used when the property value is retrieved. Here's a link to more info: http://www.martinfowler.com/eaaCatalog/lazyLoad.html

    HTH,

     

     


    Paul Delcogliano
    Saturday, October 22, 2011 3:46 AM
  • Good Bye for very last time  ......

     

    Please do ask microsoft support

     

    Thank you...... for the last time.


    PHIJO MP
    Saturday, October 22, 2011 6:42 AM
  • Hi Paul,

    Not the solution i was looking for but thanks.

    Kind Regards,

    Flaminio

    Monday, October 24, 2011 7:45 AM