Ticket #118 (closed defect: fixed)
商城6.1版出现的慢语句
| Reported by: | huangzhong | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | |
| Component: | 商家后台 | Version: | 6.1 |
| Keywords: | Cc: | ||
| Due Date: | 18/10/2012 |
Description
- 现象
dba监测到一条慢语句,18万条数据,耗时20多秒
select n.* from ent_news n ,ent_company ec where n.status!=2 and ec.status>=0 and n.user_id = ec.id and n.product_id is not null and n.city ='北京' order by n.last_update_date desc
这是经销商库中的商情列表,拿北京地区的商情按时间倒序,然后分页显示
- 解决方案
此处的商情中只过滤了被否决的,其实从业务角度上来说,过期的商情也是没意义的,加上过期商情限制的话,数据量会少很多,这样做排序和分页会快很多,把n.status!=2改为
n.status<2,改完之后时间小于1秒
Change History
Note: See
TracTickets for help on using
tickets.
![(please configure the [header_logo] section in trac.ini)](http://www1.pconline.com.cn/global/2008/images/jss/m_logo091125.jpg)
能直接加上limit么,限制返回集的大小