如何在不增加日志文件的情况下重新加载表?

发布于 2024-09-07 20:30:54 字数 245 浏览 5 评论 0原文

我有以下场景,每天晚上使用 SQL Server 2008 中的 SSIS 运行:

  • 创建一些临时文件。 从 ODBC 数据源导入数据
  • 表,并在导入完成后 ,删除现有表,并将 temp.table 重命名为 temp.table。表与删除的表同名

我需要在 SSIS 作业或 SQL Server 设置中执行哪些操作才能最大限度地减少日志记录?我不想关闭整个数据库的日志记录,因为只有这几个表每晚更新。

I have the following scenario which runs every night using SSIS in SQL Server 2008:

  • create a few temp. tables, and import data from an ODBC data source
  • when the imports are complete, drop existing tables, and rename the temp. tables to the same name as the dropped tables

What do I need to do in either my SSIS job or SQL Server settings to minimize the logging? I don't want to turn off logging for the whole db, since there are only these few tables that get updated nightly.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

回眸一遍 2024-09-14 20:31:05

我会将这些表放在另一个启用了简单恢复的数据库中,然后在另一个数据库中使用同义词使它们显示在本地。

这将使您能够利用其他人为这些表推荐的简单恢复模型和快速加载选项。

I would put these tables in another db with simple recovery enabled, and then use a synonym in the other database to make them appear local.

This will let you leverage the simple recovery model and fast load option recommended by others for these tables.

灰色世界里的红玫瑰 2024-09-14 20:31:04

我认为最好的选择是在表加载之前立即将恢复模式更改为批量记录,然后切换回完整模式。请务必阅读要考虑的事项 (http://msdn.microsoft. com/en-us/library/ms190203.aspx)在实施之前。这可以通过 ALTER DATABASE 语句来完成,这些语句可以添加到 SSIS 包的控制流中:

-- switch to bulk-logged mode
alter database <dbname,,> set recovery bulk_logged;

-- switch back to full
alter database <dbname,,> set recovery full;

虽然我(目前)也依赖更频繁的日志备份来保持日志驯服,但这更像是艺术而不是科学。就像大多数艺术一样,总有一些东西会让你感到惊讶;不幸的是,这些惊喜更像是去看牙医:痛苦但可能是可以预防的:)。

我还想知道您是否在 oledb 目标组件上使用快速加载选项(假设您正在使用该选项)。这也应该是最少的日志记录。有一个很好的白皮书,介绍了多种技术加载可能值得检查的数据时的性能(做好准备,这是一件好事)。 。 。也许它可以给你更多的想法!

I would think that changing the recovery model to be bulk-logged immediately prior to the table loads then switching back to full would be the best option. Be sure to read up on things to consider (http://msdn.microsoft.com/en-us/library/ms190203.aspx) before implementation. This can be accomplished via ALTER DATABASE statements that could be added to the control flow of your SSIS package:

-- switch to bulk-logged mode
alter database <dbname,,> set recovery bulk_logged;

-- switch back to full
alter database <dbname,,> set recovery full;

Though I also have (and currently) relied on more frequent log backups to keep the log tamed, this is more art than science. Like most art, something's bound to surprise you; unfortunately, these surprises are more like a visit to the dentist: painful and probably preventable :).

I would also wonder if you're using the fast-load option on the oledb destination component (presuming that's what you're using). This should be minimally logging as well. There's a good white paper on numerous techniques for performance when loading data that might be worth checking out as well (be prepared, it's a doozey) . . . perhaps it can give you a few more ideas!

ゃ懵逼小萝莉 2024-09-14 20:31:03

更频繁地备份事务日志可以保持其大小,并且不需要增加日志大小。我还发现现在存储空间很便宜,您可以将 LDF 文件重新定位到该驱动器以方便释放可用空间。

More frequent backups to transaction log can keep up the size and not demanding for increase in log size. Also I see that storage is cheap now a days where you can relocate your LDF file to that drive for ease of free space.

℡Ms空城旧梦 2024-09-14 20:31:02

是否有可能将这些表拆分到另一个数据库中?

您不仅可以单独管理日志记录设置,还可以管理日志和备份本身,因此您可以更精细地控制它。

您可以在旧数据库中创建视图,该视图指向您移动到新数据库的表,因此代码甚至可能不需要进行太多更改。

Is there a possibility of splitting these tables out into another database?

You would be able to manage not only the logging settings separately, but the logs and backups themselves and thus you could control it with much more granularity.

You could create views in the old database which point to the tables you move to the new database, so code might not even need to change much.

够运 2024-09-14 20:31:00

不幸的是,日志记录是数据库级别的设置。也许您可以将负载加载到单独的数据库中(使用 SIMPLE 或 BULK LOGGED),然后假设该位成功,则更新现有表。

Unfortunately logging is a database level setting. Perhaps you could do the load into a separate DB (with SIMPLE or BULK LOGGED) and then, presuming that bit is successful, UPDATE your existing tables.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文