I am working on an auto trade website. On the page where Ad list gets displayed, I plan to display the number of Ad for different categories: for example, for location: I will display something like “Vancouver (50), Richmond (12), Surrey (20)”. For vehicle make, the following will be shown “Honda (20), Ford(12), VW (24)”.
I am not sure if I should pull ALL the ad from the db into a List first, bind one page of the result to gridview control, and then compute stats for each category using Linq. if course I will limit the number of rows pulled from the db using some kind of condition – maybe set the MAX # of rows to be returned as 500.
My major concern is – is this going to be a memory hog?
It is bad idea to count rows in the memory. Use
which is much more efficient.
Also review possibility to cache these values. Assuming that multiple people loads your page simultaneously, but count of cars don’t changes quicker then once per 1 minute – apply caching strategy to obsolete values over 1 min.