SQL Server 2008 中 CLR 中的线程
我有一个在 SQL Server2008
下运行的 CLR
进程。它构建了多个表数据的缓存以保存在静态类中以供其他调用稍后使用。
我的问题是,我可以通过生成线程来加载缓存中的每个数据集/表来改进加载此缓存的过程吗?
我过去一直回避这一点,因为各种帖子建议将线程管理留给 SQL Server
。不过我真的可以加快这个过程。 目前,它是加载每个数据集的顺序过程。如果我可以同时运行这些,那就非常方便了。我在 CLR
之外多次完成此过程,以获得一些额外的性能提升。
非常感谢任何想法帮助提示。
I have a CLR
process which runs under SQL Server2008
. It builds a cache of several tables data to hold in a static class for use later by other calls.
My question is could I improve the process of loading this cache by spawning threads to load each data set/ table in my cache?
I've steared clear of this in the past as various posts have suggested leave the thread management to SQL Server
. However I could really do with speeding up this process.
Currently its a sequential process to load each data set. If I could run these concurrently it would be very handy. A process I've done many atime outside of the CLR
cover to get some extra performance gains.
Any ideas help tips very much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用线程,但它们必须正常工作。否则您将失去使用它们的好处。
来自CLR 主机环境
SQL Server 和 CLR 的工作原理一起
You can use threads, but they must behave. Otherwise you'll lose the benefits of using them.
From the CLR Host Environment
How SQL Server and the CLR Work Together
跨调用共享静态数据 - 对于 CLR 调用来说不是一个好的计划:
SQL Server 文档
Static data shared across invocations - not a good plan for CLR calls:
SQL Server documentation