create unique index IND_MSCID on FACT_SALE (YEARMONTH, SHOPID, ANALYSE_ID, CATEID)update fact_sale a set (zyamt)=(select zy from t_msc_amt b
where a.shopid=b.shopid and a.yearmonth=b.year_month and a.cateid=b.dl and ANALYSE_ID='01'
and b.zy_ly='自营')以上更新语句为什么总是全盘扫描,索引没用上. 请问要怎么建呢,t_msc_amt是临时表,尽量不在它上面建.
where a.shopid=b.shopid and a.yearmonth=b.year_month and a.cateid=b.dl and ANALYSE_ID='01'
and b.zy_ly='自营')以上更新语句为什么总是全盘扫描,索引没用上. 请问要怎么建呢,t_msc_amt是临时表,尽量不在它上面建.
数据量大的时候,效率比较低, 还不如先关联出临时结果,然后再delete、insert
一般是t1全盘扫描,t2引用索引
建了索引,查询时候不是100%用索引的
http://blog.csdn.net/pathuang68/archive/2009/04/16/4084116.aspx
和
http://blog.csdn.net/pathuang68/archive/2009/04/16/4084139.aspx