log usage difference insert vs update
Posted in 2018
Topics: General Discussion
I created a table as:
create table t1(c char(5120));loaded a file of about 5 thousand lines (on average string of 25 bytes). It
consumed around 5MB log space. But if i update these records
update t1 set c=c||c where 1=1;then log space consumption is around 1.15 MB (roughly 23%).
Why this update consumed so little logs compared to insert?
Version: Informix IDS 12.1 FC10
Original post:
I created a table as:
create table t1(c char(5120));loaded a file of about 5 thousand lines (on average string of 25 bytes). It
consumed around 5MB log space. But if i update these records
update t1 set c=c||c where 1=1;then log space consumption is around 1.15 MB (roughly 23%).
Why this update consumed so little logs compared to insert?
Version: Informix IDS 12.1 FC10
Response:
Even though you are only inserting 25 bytes, since you have the row defined as
char(5120), for the insert, it is logging the entire image of the row, which
will include the space padded full size of the row. When you do your update,
as an optimization, it can only be logging the delta of the row (but I think
you get a before and after log record), so it's not logging the full 5120
bytes. In some cases you can get the full row logging on updates but that
happens if I think ER or CDC exist on the table (I don't recall all the
conditions that trigger full row logging of updates off the top of my head).
You can look at the log record using onlog and a portion of that output is the
size of the log records. So if you looked, I believe your insert you would see
fewer larger log records, and for the update, you would see more, smaller log
records because inserts and updates are logged differently.
Jacques Renaut
HCL Informix Advanced Support
I am not able to understand the logs output, but yes it is logging differently in insert and update case. But logs consumption is very low even when i tried the string size of 5000 bytes in update query.