473,385 Members | 1,402 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

estimate log size of "insert into...select * from..."

How to estimate the size of log space when I need to run "INSERT INTO
tgt_tbl SELECT * FROM src_tbl WHERE..." ?
What is the difference of before image between the above INSERT stmt and the
following:
begin transaction
INSERT INTO tgt_tbl VALUES (...);
...
INSERT INTO tgt_tbl VALUES (...);
end transaction;
Nov 12 '05 #1
4 6398

"Fan Ruo Xin" <fa*****@sbcglobal.net> wrote in message
news:EF***************@newssvr31.news.prodigy.com. ..
How to estimate the size of log space when I need to run "INSERT INTO
tgt_tbl SELECT * FROM src_tbl WHERE..." ?
What is the difference of before image between the above INSERT stmt and the following:
begin transaction
INSERT INTO tgt_tbl VALUES (...);
...
INSERT INTO tgt_tbl VALUES (...);
end transaction;


A rough estimate of how much log space will be needed is:
log space needed (in 4K pages) = number_of_rows * row_length (in bytes) *
1.05 (for log record overhead) / 4096

--
Matt
Nov 12 '05 #2

"Matt Emmerton" <ma**@gsicomp.on.ca> wrote in message
news:pt********************@rogers.com...

"Fan Ruo Xin" <fa*****@sbcglobal.net> wrote in message
news:EF***************@newssvr31.news.prodigy.com. ..
How to estimate the size of log space when I need to run "INSERT INTO
tgt_tbl SELECT * FROM src_tbl WHERE..." ?
What is the difference of before image between the above INSERT stmt and the
following:
begin transaction
INSERT INTO tgt_tbl VALUES (...);
...
INSERT INTO tgt_tbl VALUES (...);
end transaction;


A rough estimate of how much log space will be needed is:
log space needed (in 4K pages) = number_of_rows * row_length (in bytes)

* 1.05 (for log record overhead) / 4096

--
Matt

Thanks, Matt. I thought the formula is for my second case. AFAIK, the first
one will use smaller log space than the second one. But I can't find any
reference from the db2 documentation. Do you know what the difference is
between the before&after image when db2 log both transactions?
Nov 12 '05 #3

"Fan Ruo Xin" <fa*****@sbcglobal.net> wrote in message
news:QQ*******************@newssvr19.news.prodigy. com...

"Matt Emmerton" <ma**@gsicomp.on.ca> wrote in message
news:pt********************@rogers.com...

"Fan Ruo Xin" <fa*****@sbcglobal.net> wrote in message
news:EF***************@newssvr31.news.prodigy.com. ..
How to estimate the size of log space when I need to run "INSERT INTO
tgt_tbl SELECT * FROM src_tbl WHERE..." ?
What is the difference of before image between the above INSERT stmt
and the
following:
begin transaction
INSERT INTO tgt_tbl VALUES (...);
...
INSERT INTO tgt_tbl VALUES (...);
end transaction;
A rough estimate of how much log space will be needed is:
log space needed (in 4K pages) = number_of_rows * row_length (in

bytes) *
1.05 (for log record overhead) / 4096

--
Matt

Thanks, Matt. I thought the formula is for my second case. AFAIK, the

first one will use smaller log space than the second one. But I can't find any
reference from the db2 documentation. Do you know what the difference is
between the before&after image when db2 log both transactions?


If both transactions do the same amount of work (ie, same number of inserts,
same data), then the amount of log space used will be the same.

--
Matt Emmerton
Nov 12 '05 #4

"Matt Emmerton" <ma**@gsicomp.on.ca> wrote in message
news:qo********************@rogers.com...

"Fan Ruo Xin" <fa*****@sbcglobal.net> wrote in message
news:QQ*******************@newssvr19.news.prodigy. com...

"Matt Emmerton" <ma**@gsicomp.on.ca> wrote in message
news:pt********************@rogers.com...

"Fan Ruo Xin" <fa*****@sbcglobal.net> wrote in message
news:EF***************@newssvr31.news.prodigy.com. ..
> How to estimate the size of log space when I need to run "INSERT INTO > tgt_tbl SELECT * FROM src_tbl WHERE..." ?
> What is the difference of before image between the above INSERT stmt and the
> following:
> begin transaction
> INSERT INTO tgt_tbl VALUES (...);
> ...
> INSERT INTO tgt_tbl VALUES (...);
> end transaction;

A rough estimate of how much log space will be needed is:
log space needed (in 4K pages) = number_of_rows * row_length (in
bytes)
*
1.05 (for log record overhead) / 4096

--
Matt

Thanks, Matt. I thought the formula is for my second case. AFAIK, the

first
one will use smaller log space than the second one. But I can't find any
reference from the db2 documentation. Do you know what the difference is
between the before&after image when db2 log both transactions?


If both transactions do the same amount of work (ie, same number of

inserts, same data), then the amount of log space used will be the same.

--
Matt Emmerton

Hi, Matt,
I did a test (maybe) two months ago - I build a table A and load a couple of
records, and copy the ddl and data to tableB.
The "delete from tableA" and empty tableA and then "import ... into tableA"
without COMMITCOUNT failed as "log full". But not "insert into tableA select
* from tableB".
I will double check if I can reproduce the scenario.
Thanks,
FRX
Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: newbie_mw | last post by:
Hi, I need urgent help with a novice problem. I would appreciate any advice, suggestions... Thanks a lot in advance! Here it is: I created a sign-up sheet (reg.html) where people fill in their...
1
by: newbie_mw | last post by:
Seems my post was buried in more cries for help :-) I will try again. It's probably a very novice question so please take a look! Thanks!...
2
by: EricRobineau | last post by:
hello I have a DB with many inter-related tables (MySQL) My main table called "content" has almost only foreign keys (integers) some have a 3 level relation (ex: content->city->region->country) ...
5
by: Chad Richardson | last post by:
Is there a way in SQL Server 2000 to extract data from a table, such that the result is a text file in the format of "Insert Into..." statements, i.e. if the table has 5 rows, the result would be 5...
5
by: Just D. | last post by:
How can we get the browser window size from C# codebehind? What's the easiest way to do that? Just D.
3
by: Ed | last post by:
Hi, I want to load data to a table in Sql Server from a dataset table in my vb.net app using a dataAdapter. I know how to do this as follows (my question is to see if I can reduce the amount...
0
by: abhinav123 | last post by:
hello frnds i need to send the page size from the code itself and not from the report designer how can i do it for ex---my page size is 06 ht and 08 wdt
23
by: Al Grant | last post by:
I have a 'printable' button to generate printable output and want this to use A3 if available, irrespective of the user's default printer setting. Is there any way to set a page's preferred...
1
by: Avi | last post by:
Hi all, I would like to remove the oldest rows beyond a predefined size from a DataTable. Is it possible to remove a bulk of rows in one shot or do I have to loop and do a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.