Ticket #76 (reopened 优化) — at Version 5
产品库动态产品文章、图片读取的代码优化
| Reported by: | huangxianduan | Owned by: | huangxianduan |
|---|---|---|---|
| Priority: | major | Milestone: | |
| Component: | 产品库 | Version: | 产品库3.0 |
| Keywords: | 数据库优化 | Cc: | |
| Due Date: | 15/12/2011 |
Description (last modified by chenchongqi) (diff)
由于产品库动态数据库的产品文章表访问频率非常的高,虽然单句执行成本低,但是一个小时的访问次数达到18万,占了数据库服务器比较多资源。
检查代码发现动态的页面几乎都是公用了OuterAction的detail方法,这个方法里面会把所有跟产品相关的所有信息查出来,不管当前的访问请求是否需要这些信息,再加上有些查询是没有做mc缓存的,而且文章表的数据量比较大,这样就导致了频繁的读取造成数据库服务器负载高
优化:检查代码判断是否需要文章和图片数据。如果不需要就不做数据的读取,减少对数据库读取的频率,降低数据库服务器的压力。
Change History
Note: See
TracTickets for help on using
tickets.
![(please configure the [header_logo] section in trac.ini)](http://www1.pconline.com.cn/hr/2009/global/images/logo.gif)

优化后的相关代码:
if(template != null && (template.indexOf("product_1.jsp") != -1 || template.indexOf("wap_product.jsp") != -1)){ request.setAttribute(CURRENT_PRODUCT_PIC, oProduct.getProductPicWEB(cp)); } if(template != null && (template.indexOf("product_4.jsp") != -1 || template.indexOf("product_4_art.jsp") != -1 || template.indexOf("product_5.jsp") != -1)) { request.setAttribute(CURRENT_ARTICLE_LINK, oProduct.getProductArticleLinkWEB()); }