建立全文索引



--为GoodName列建立全文索引数据元,PK_EC_Goods为ec_goods表中由主键所建立的唯一索引,这个参数是必需的。
execute sp_fulltext_table 'ec_goods','create','GoodsSearch','PK_EC_Goods'
--设置全文索引列名
execute sp_fulltext_column 'ec_goods','goodname','add'
--建立全文索引
--activate,是激活表的全文检索能力,也就是在全文目录中注册该表
execute sp_fulltext_table 'ec_goods','activate'
--填充全文索引目录
execute sp_fulltext_catalog 'GoodsSearch','start_full'
--查询全文索引是否建立完毕(0:完毕;1:正在建立)
select fulltextcatalogproperty('GoodsSearch','populateStatus')




execute sp_fulltext_table ‘book’,‘create’, ‘ft_test’,‘pk_title’
//设置全文索引列名
execute sp_fulltext_column ‘book’, ‘title’, ‘add’
execute sp_fulltext_column ‘book’,‘notes’, ‘add’
//建立全文索引
execute sp_fulltext_table ‘book’, ‘activate’
//填充全文索引目录
execute sp_fulltext_catalog ‘ft_test’, ‘start_full’
至此,全文索引建立完毕。

update ec_soitem  set ordertime=b.ordertime from ec_soitem  a  join EC_SalesOrder b 
on (a.SOID=b.SOID)


select a.PayableValue,a.Rownumber,EC_Goods.GoodCode,EC_Goods.GoodName,
0.00 as Rate  
from EC_Goods 
inner join (
select EC_SOItem.GoodID,SUM(EC_SOItem.PayableValue) PayableValue,
       ROW_NUMBER() over(order by SUM(EC_SOItem.PayableValue) desc) as Rownumber
 from EC_SOItem where  OrderTime>='2016-11-01'and OrderTime<'2016-12-01'
group by EC_SOItem.GoodID) a on a.GoodID=EC_Goods.GoodID 
where Rownumber<=10
go--我记得优化这个的时候,是修改了表结构  把 ec_salesorder表里面的一些字段转移到ec_soitem,为了不要进行表连接,(因为两个表的数据量都是千万级的)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值