Question

This is a very confusing problem for me.

I am running a db2 loading operation, yet it makes a big difference whether to redirect the stdout to a local log file or not.

Here is the statistics:

[dbadmin@mymachine:/home/dbadmin]# time db2 -tv "LOAD FROM ./mat.AK OF DEL METHOD P (1,2,3) MESSAGES ./mat.AK.log REPLACE INTO myschema.mytable (col1, col2, col3) STATISTICS YES AND INDEXES ALL INDEXING MODE REBUILD;" >> ./mat.AK.log

real    1m56.75s
user    0m0.00s
sys     0m0.01s

[dbadmin@mymachine:/home/dbadmin]# time db2 -tv "LOAD FROM ./mat.AK OF DEL METHOD P (1,2,3) MESSAGES ./mat.AK.log REPLACE INTO myschema.mytable (col1, col2, col3) STATISTICS YES AND INDEXES ALL INDEXING MODE REBUILD;"

Number of rows read         = 69379
Number of rows skipped      = 0
Number of rows loaded       = 69379
Number of rows rejected     = 0
Number of rows deleted      = 0
Number of rows committed    = 69379



real    0m1.42s
user    0m0.01s
sys     0m0.00s

I am not sure why the redirection of stdout to ./mat.AK.log costs nearly 2 minutes for the whole operation, while it takes less than 2 seconds to make it into the db2 table without the redirection.

Any idea, please?

Was it helpful?

Solution

It turned out that the cause of the problem is a racing condition between the "MESSAGES" command in the LOAD operation and the redirection directive at the tail. Keeping both of them and have both of them pointed to the same file creates a racing condition and caused the delay.

After I discarded one of the two, the problem got solved.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top