rajesh... wrote:
Serge, I have read your articles before. Which one exactly you are
referring to here? I havent found enough evidence to support my
finding. Are you agreeing that not null v. nullable can degrade
performance as much as 2 times for inserting the same data?
I have some thoughts....
Insert through UNION ALL depends on check constraints.
Note that a check constraint of the form: (c1 BETWEEN 1 AND 5) will
permit NULL to be inserted for c1.
That is with a NULLable column
T1: (c1 BETWEEN 1 AND 6)
T2: (c1 BETWEEN 7 AND 10)
does not provide a guaranteed partitioning.
That means DB2 has to "do it the hard way" (as described in my article).
It needs to test all tables and count the number of successes.
If DB2 can prove the check constraints partition it can either
"parameterize" the INSERT (that is use a normal INSERT into a single
table template - you will find that the plan looses all but one table)
or at least it can do runtime elimination.
So there are really "three gears" to INSERT through UNION ALL.
Feel free to get explains (db2exfmt preferred) and I shoudl be able to
tell you what happens.
It may be that all you need is to improve your check constraints to tell
DB2 exactly where NULLs are supposed to end up:
T1: (c1 BETWEEN 2 AND 6 AND c1 IS NOT NULL)
T2: (c1 BETWEEN 7 AND 10 AND c1 IS NOT NULL)
T3: (c1 IS NULL)
Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab