开发者

pull everything from db and then compute stats?

开发者 https://www.devze.com 2023-01-10 02:32 出处:网络
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 \

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 f开发者_StackOverflow中文版irst, 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

SELECT COUNT() FROM... [ GROUP BY ]

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消