Forum


HomeHomePremiumPremiumDevelopmentDevelopmentDAL2 - GetById() is executing slowlyDAL2 - GetById() is executing slowly
Previous
 
Next
New Post
11/15/2013 1:49 PM
 

While developing some code to work with a large data table I noticed that the GetById() function was taking several seconds to return a result.  The caching was enabled and subsequent calls to the same function were also taking several seconds to execute. 

I call my table a large data table but it bothers me somewhat to do so.  The table has ~800K rows in it and although it's larger than most tables I work with, it seems like a normal and reasonable thing to have this many entries in a table.  I expect objects (in this case the DAL2 repository) that interact with databases should be designed to handle data tables that have at least this many entries. 

The DAL2 repository does not handle this many entries well with GetById().  If the repository is used as you would normally expect to use it, you can shoot yourself in the foot with large data sets.  My solution was to abandon the use of GetById() and use Find() with custom caching.  The full technical details surrounding my experiences and the solution can be found in another post if interested, http://stackoverflow.com/questions/20....

 
New Post
11/16/2013 5:07 AM
 

Andy,

I think you mention on your stackoverflow post that the first time you call GetById, it caches the entire table.   I would be interested in knowing how the Scope attribute is configured on your DAL2 model class.  The question is whether you should do caching at all for this table.  If you are mainly doing single record retrieval/update by key, on a table this size, you should probably turn off caching.  You can manually cache the record if it is frequently access in the session or in the DNN cache.  

Caching in the DAL in my mind should only be done when you have data segmented into reasonably sized chunks.  That segmentation is usually by moduleId or PortalId, etc where that field is indexed in the table and you often have to retrieve the records in those segmented groups.

 
New Post
11/18/2013 5:23 AM
 

Thanks for taking a look at this.  I have this set as an attribute on the class:

Cacheable("MYCACHENAME", CacheItemPriority.Default, 20) 

I don't specify a scope as the data is not tied to a specific site or portal.  This database table is a tax rate table broken down by US and Canadian zip codes.  Because of this, most hits to the table are going to be SELECTS other than the monthly full table update.  The tax rates will be hit several times during the checkout process so cache seemed like it would be used although not extensively.  Based on your input I should probably not use caching here.

 
Previous
 
Next
HomeHomePremiumPremiumDevelopmentDevelopmentDAL2 - GetById() is executing slowlyDAL2 - GetById() is executing slowly



Try FREE
30 days money back guaranteed