前言
前些日子装数据库的笔记本硬盘炸了,不得不从云盘里恢复了数据,但是相应的一些数据库的优化又从头构造。昨天在DBA大神的帮助下再次优化了一下QQ群关系库的引索,前后查询只需要1 - 2秒,已经可以说非常快了,想着前些日子好多人咨询QQ群关系这块的内容,就把优化引索的语句放上来吧。(P.s 不经常在线,有要交流的可以+ Q465212916)
- Group引索
set xact_abort on
begin tran
declare @dbIdx int = 1
while @dbIdx <= 11
begin
declare @tblIdx int = 1
declare @tblName varchar(50)
while @tblIdx <= 100
begin
set @tblName = 'GroupData' + CONVERT(varchar(2), @dbIdx) + '.dbo.Group'
set @tblName += CONVERT(varchar(5), (@dbIdx - 1) * 100 + @tblIdx)
exec ('create index ix_Group_QQNum on ' + @tblName + '(QQNum)');
print @tblname + ' OK'
set @tblIdx += 1 --循环递增
end
set @dbIdx += 1 --外层递增
end
commit tran
- Qunlist引索
set xact_abort on
begin tran
declare @dbIdx i

博主分享了在DBA帮助下优化QQ群关系库索引的经验,现在查询时间仅需1-2秒。提供了Group和Qunlist的索引优化语句,适合需要QQ群关系查询效率提升的读者。

2453

被折叠的 条评论
为什么被折叠?



