简体   繁体   English

没有交易的存储过程

[英]Stored procedure without transaction

I have a stored procedure that performs calculations and stores a large amount of data in new tables, in another database. 我有一个存储过程,该过程执行计算并将大量数据存储在另一个数据库的新表中。 If anything goes wrong, I just drop the tables. 如果出了什么问题,我就放下桌子。

I've already set the recovery mode for this database as simple, as the data is available elsewhere. 我已经将此数据库的恢复模式设置为简单,因为其他地方都可以使用该数据。 Is there anything else I can do in the stored procedure to limit writing to the transaction log or remove transactions entirely to speed up the process? 在存储过程中,我还能做些其他事情来限制写入事务日志或完全删除事务以加快过程吗?

I suggest you that using SSIS package in order to convert data from one database to another database. 我建议您使用SSIS包将数据从一个数据库转换到另一个数据库。 in SSIS you can control converted data and can use balk insert. 在SSIS中,您可以控制转换后的数据,并可以使用禁止插入。 In buck insert mode you limit your database to write transaction logs completely. 在buck插入模式下,您限制数据库完全写入事务日志。

It is impossible to completely eliminate transaction log from the equation in SQL Server. 从SQL Server中的公式中完全消除事务日志是不可能的。

You may try to check bulk logged recovery model in conjunction with bulk insert , but if your calculations are complex and cannot be expressed within a single select statement, it could be worth trying SSIS. 您可以尝试与bulk insert一起检查批量记录的恢复模型,但是如果您的计算很复杂并且不能在单个select语句中表示,那么值得尝试SSIS。

I ran into similar situations even while using SSIS where my staging database(s) kept logs more then 10 times the size of the actual data (on simple logging and using bulk insert). 即使在使用SSIS时,我也遇到了类似的情况,其中我的登台数据库将日志保存的日志大小超过了实际数据大小的10倍(通过简单日志记录和使用批量插入)。 After lots of searching I have found that it is not feasable to prevent this from happening when doing large data operations like loading a datawarehouse. 经过大量搜索,我发现在进行大数据操作(例如加载数据仓库)时阻止这种情况的发生是不可行的。 Instead it is easier to just clean up after you are done by shrinking the log. 取而代之的是,通过收缩日志来完成后更容易清理。

dbcc shrinkfile dbcc收缩文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM