首先创建一个包含易失性列的表以减少日志大小

发布于 2024-10-03 02:30:56 字数 710 浏览 0 评论 0原文

我对此不太确定,但我想我之前读过它,我想知道这是对还是错:

创建表时,最好先放置易失性列,然后放置静态列。我的意思是,将可更新的列和不可更新的列放在最后。 这有利于减少事务日志的大小,因为每次修改一行时,日志都会写入旧行以及新行的列,直到最后一次更新。

Row

ID-PK, code, name , message
1    , 10 , "John Doe", "A funny message"

Update to

1    , 10 , "John Doe", "The message was changed."

在这种情况下,日志将完全写入新行。但是,如果我们更改列的顺序:

ID-PK, message , code, name<br/>
1    , "A funny message"         , 10 , "John Doe"

更新为

1    , "The message was changed.", 10 , "John Doe"

事务日志将仅写入直到最后修改的列(1,“消息已更改。”),这可以提高将日志写入和传送到另一个列时的性能机器就像使用 HADR 时一样。

我想知道这是否属实,以及在哪里可以找到相关信息。

I am not sure about this, but I think I read it before, and I would like to know if that is true or false:

When creating tables, it is better to put volatile columns first and then the static columns. I mean, to put the columns that will be updatable, and the not updatable at the end.
This is good to reduce the size of the transaction log because each time a row is modified, the log will write the old row, and the columns of the new row till the last updated.

Row

ID-PK, code, name , message
1    , 10 , "John Doe", "A funny message"

Update to

1    , 10 , "John Doe", "The message was changed."

In this case, the log will write completely the new row. However, if we change the order of the columns:

Row

ID-PK, message , code, name<br/>
1    , "A funny message"         , 10 , "John Doe"

Update to

1    , "The message was changed.", 10 , "John Doe"

The transaction log will only write the till the last modified column (1, "The message was changed.") and this could improve the performance while writting and shipping logs to another machine like when using HADR.

I would like to know if this is true, and where can I found information about this.

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

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

发布评论

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

评论(1

夏了南城 2024-10-10 02:30:56

当未启用完整数据更改捕获时,DB2 LUW 日志记录从数据更改的第一个字节开始,一直到数据更改的最后一个字节。 IBM 在其在线文档的标题为“对列进行排序以最大程度地减少更新日志记录"

频繁更新的列应分组在一起,并在表定义的末尾或末尾进行定义。这会带来更好的性能、更少的记录字节数和更少的写入日志页,以及执行大量更新的事务所需的活动日志空间更小。

When full data change capture is not enabled, DB2 LUW log records begin with the first byte where data changes and continue to the last byte where data changes. IBM offers the following recommendation in a section of their online documentation titled "Ordering columns to minimize update logging"

Columns which are updated frequently should be grouped together, and defined towards or at the end of the table definition. This results in better performance, fewer bytes logged, and fewer log pages written, as well as a smaller active log space requirement for transactions performing a large number of updates.

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