大牛帮忙 100G数据库 执行效率问题 如何弄成存储过程
本帖最后由 uuwangorg 于 2013-04-13 14:08:30 编辑 select * from [QunInfo1].[dbo].[QunList1] where [QunInfo1].[dbo].[QunList1].[Class]='315' union all select * from [QunInfo1].[dbo].[QunList2] where [QunInfo1].[dbo].[QunList2].[Class]='315' union all select * from [QunInfo1].[dbo].[QunList3] where [QunInfo1].[dbo].[QunList3].[Class]='315' union all select * from [QunInfo1].[dbo].[QunList4] where [QunInfo1].[dbo].[QunList4].[Class]='315' union all select * from [QunInfo1].[dbo].[QunList5] where [QunInfo1].[dbo].[QunList5].[Class]='315' union all select * from [QunInfo1].[dbo].[QunList6] where [QunInfo1].[dbo].[QunList6].[Class]='315' union all select * from [QunInfo1].[dbo].[QunList7] where [QunInfo1].[dbo].[QunList7].[Class]='315' union all select * from [QunInfo1].[dbo].[QunList8] where [QunInfo1].[dbo].[QunList8].[Class]='315' union all select * from [QunInfo1].[dbo].[QunList9] where [QunInfo1].[dbo].[QunList9].[Class]='315' union all select * from [QunInfo1].[dbo].[QunList10] where [QunInfo1].[dbo].[QunList10].[Class]='315' union all select * from [QunInfo2].[dbo].[QunList11] where [QunInfo2].[dbo].[QunList11].[Class]='315' union all select * from [QunInfo2].[dbo].[QunList12] where [QunInfo2].[dbo].[QunList12].[Class]='315' union all select * from [QunInfo2].[dbo].[QunList13] where [QunInfo2].[dbo].[QunList13].[Class]='315' union all select * from [QunInfo2].[dbo].[QunList14] where [QunInfo2].[dbo].[QunList14].[Class]='315' union all select * from [QunInfo2].[dbo].[QunList15] where [QunInfo2].[dbo].[QunList15].[Class]='315' union all select * from [QunInfo2].[dbo].[QunList16] where [QunInfo2].[dbo].[QunList16].[Class]='315' union all select * from [QunInfo2].[dbo].[QunList17] where [QunInfo2].[dbo].[QunList17].[Class]='315' union all select * from [QunInfo2].[dbo].[QunList18] where [QunInfo2].[dbo].[QunList18].[Class]='315' union all select * from [QunInfo2].[dbo].[QunList19] where [QunInfo2].[dbo].[QunList19].[Class]='315' union all select * from [QunInfo2].[dbo].[QunList20] where [QunInfo2].[dbo].[QunList20].[Class]='315' union all select * from [QunInfo3].[dbo].[QunList21] where [QunInfo3].[dbo].[QunList21].[Class]='315' union all select * from [QunInfo3].[dbo].[QunList22] where [QunInfo3].[dbo].[QunList22].[Class]='315' union all select * from [QunInfo3].[dbo].[QunList23] where [QunInfo3].[dbo].[QunList23].[Class]='315' union all select * from [QunInfo3].[dbo].[QunList24] where [QunInfo3].[dbo].[QunList24].[Class]='315' union all select * from [QunInfo3].[dbo].[QunList25] where [QunInfo3].[dbo].[QunList25].[Class]='315' union all select * from [QunInfo3].[dbo].[QunList26] where [QunInfo3].[dbo].[QunList26].[Class]='315' union all select * from [QunInfo3].[dbo].[QunList27] where [QunInfo3].[dbo].[QunList27].[Class]='315' union all select * from [QunInfo3].[dbo].[QunList28] where [QunInfo3].[dbo].[QunList28].[Class]='315' union all select * from [QunInfo3].[dbo].[QunList29] where [QunInfo3].[dbo].[QunList29].[Class]='315' union all select * from [QunInfo3].[dbo].[QunList30] where [QunInfo3].[dbo].[QunList30].[Class]='315' union all select * from [QunInfo4].[dbo].[QunList31] where [QunInfo4].[dbo].[QunList31].[Class]='315' union all select * from [QunInfo4].[dbo].[QunList32] where [QunInfo4].[dbo].[QunList32].[Class]='315' union all select * from [QunInfo4].[dbo].[QunList33] where [QunInfo4].[dbo].[QunList33].[Class]='315' union all select * from [QunInfo4].[dbo].[QunList34] where [QunInfo4].[dbo].[QunList34].[Class]='315' union all select * from [QunInfo4].[dbo].[QunList35] where [QunInfo4].[dbo].[QunList35].[Class]='315' union all select * from [QunInfo4].[dbo].[QunList36] where [QunInfo4].[dbo].[QunList36].[Class]='315' union all select * from [QunInfo4].[dbo].[QunList37] where [QunInfo4].[dbo].[QunList37].[Class]='315' union all select * from [QunInfo4].[dbo].[QunList38] where [QunInfo4].[dbo].[QunList38].[Class]='315' union all select * from [QunInfo4].[dbo].[QunList39] where [QunInfo4].[dbo].[QunList39].[Class]='315' union all select * from [QunInfo4].[dbo].[QunList40] where [QunInfo4].[dbo].[QunList40].[Class]='315' union all select * from [QunInfo5].[dbo].[QunList41] where [QunInfo5].[dbo].[QunList41].[Class]='315' union all select * from [QunInfo5].[dbo].[QunList42] where [QunInfo5].[dbo].[QunList42].[Class]='315' union all select * from [QunInfo5].[dbo].[QunList43] where [QunInfo5].[dbo].[QunList43].[Class]='315' union all select * from [QunInfo5].[dbo].[QunList44] where [QunInfo5].[dbo].[QunList44].[Class]='315' union all select * from [QunInfo5].[dbo].[QunList45] where [QunInfo5].[dbo].[QunList45].[Class]='315' union all select * from [QunInfo5].[dbo].[QunList46] where [QunInfo5].[dbo].[QunList46].[Class]='315' union all select * from [QunInfo5].[dbo].[QunList47] where [QunInfo5].[dbo].[QunList47].[Class]='315' union all select * from [QunInfo5].[dbo].[QunList48] where [QunInfo5].[dbo].[QunList48].[Class]='315' union all select * from [QunInfo5].[dbo].[QunList49] where [QunInfo5].[dbo].[QunList49].[Class]='315' union all select * from [QunInfo5].[dbo].[QunList50] where [QunInfo5].[dbo].[QunList50].[Class]='315'...这里省略了 总共执行语句 有100多条 都是这个规律下来的
如果单单 用SQL 查询功能 也就是 直接执行上面的语句 要执行5分钟11秒 而且 上面这些数据库表都是创建了索引的 感觉执行 5分钟11秒还是很慢 有没有再快点的办法 几秒钟搞定的 听说存储过程 可以 具体怎么实现 给下具体代码不 我是SQL菜鸟 求大神了
[解决办法]
创建一个视图试试,把你上面的语句放进去,但是去掉where语句
用视图查询时再加where语句