求优化高手指导!1000PUB币相送,只有这么多了
我现在在写个sql,用来查询人员的消费!
涉及到表:sales_record 交易记录表,记录条数:4888407
,表中sales_record_id 为主键,purchase_date 为Clustere index,trx_type,customer_id 为index
customer_profile 人员资料表,记录数:308989 customer_id为主键,apply_date 为Clustere index
select x.customer_id,sum(x.quantity*x.actual_price)as rev,convert(char(8),x.purchase_date,112)as purchase_date
from customer_profile y inner join sales_record x
on x.customer_id=y.customer_id
where x.purchase_date>=y.apply_date and x.trx_type='va'
group by x.customer_id,convert(char(8),x.purchase_date,112)
目前的执行计划如下:
[ 本帖最后由 xnk9499 于 2008-6-30 13:24 编辑 ]
2008-6-30 13:22
11.JPG (36.59 KB)
|