Ticket #76 (reopened 优化) — at Version 5

Opened 14 years ago

Last modified 14 years ago

产品库动态产品文章、图片读取的代码优化

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

comment:1 Changed 14 years ago by huangxianduan

优化后的相关代码:

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());
}
Last edited 14 years ago by huangxianduan (previous) (diff)

comment:2 Changed 14 years ago by huangxianduan

  • Status changed from new to closed
  • Resolution set to fixed

comment:3 Changed 14 years ago by chenchongqi

  • Keywords 数据库优化 added; 优化 removed

Changed 14 years ago by chenchongqi

comment:4 Changed 14 years ago by chenchongqi

  • Status changed from closed to reopened
  • Resolution fixed deleted

更新上去后没有明显改善,需要再次检查。

comment:5 Changed 14 years ago by chenchongqi

  • Description modified (diff)
Note: See TracTickets for help on using tickets.