Summary:
----------
Updates against UNION ALL view does't do branch elimination, but
rather reads all the branches (partitions).
The case scenario(DB2 V8.1.4a ESE, AIX 5.2):
--------------------------------------------
The UNION ALL view (tv) was built on the following three sample tables
(t1,t2,t3)
CREATE TABLE T1
(I INTEGER,
S VARCHAR(10)
);
ALTER TABLE T1
ADD CONSTRAINT T1_CK CHECK
(I between 1 and 9)
ENFORCED
ENABLE QUERY OPTIMIZATION;
insert into t1 values(1,'t1-1'),(2, 't1-2'),(3,'t1-3');
CREATE TABLE T2
(I INTEGER,
S VARCHAR(10)
);
ALTER TABLE T2
ADD CONSTRAINT T1_CK CHECK
(I between 10 and 19)
ENFORCED
ENABLE QUERY OPTIMIZATION;
insert into t2 values(11,'t2-1'),(12, 't2-2'),(13,'t2-3');
CREATE TABLE T3
(I INTEGER,
S VARCHAR(10)
);
ALTER TABLE T3
ADD CONSTRAINT T1_CK CHECK
(I between 20 and 29)
ENFORCED
ENABLE QUERY OPTIMIZATION;
insert into t3 values(21,'t3-1'),(22, 't3-2'),(23,'t3-3');
create view tv as
select * from t1 union all
select * from t2 union all
select * from t3
;
db2 => select * from tv order by i,s
I S
----------- ----------
1 t1-1
2 t1-2
3 t1-3
11 t2-1
12 t2-2
13 t2-3
21 t3-1
22 t3-2
23 t3-3
9 record(s) selected.
For the statement like:
update tv set s='15'
where i=11
that tries to update data in the partition t2, the execution plan
shows no partition pruning:
Rows
RETURN
( 1)
Cost
I/O
|
1
UPDATE
( 2)
150.114
6
/---+---\
1 3
UPDATE TABLE: DB2PE
( 3) T3
125.108
5
/---+---\
1 3
UPDATE TABLE: DB2PE
( 4) T2
100.103
4
/---+---\
1 3
UNION TABLE: DB2PE
( 5) T1
75.0961
3
+----------------+----------------+
2.32831e-10 1 2.32831e-10
TBSCAN TBSCAN TBSCAN
( 6) ( 7) ( 8)
25.0322 25.0316 25.0322
1 1 1
| | |
3 3 3
TABLE: DB2PE TABLE: DB2PE TABLE: DB2PE
T1 T2 T3
Also, this statement run from db2batch indiates data access in all
those three tables:
*** Table Snapshot ***
Table Schema = DB2PE
Table Name = T3
Table File ID = 31
Table Type = USER TABLE
Rows read = 3
Rows written = 0
Accesses to overflow record = 0
*** Table Snapshot ***
Table Schema = DB2PE
Table Name = T2
Table File ID = 30
Table Type = USER TABLE
Rows read = 3
Rows written = 0
Accesses to overflow record = 0
*** Table Snapshot ***
Table Schema = DB2PE
Table Name = T1
Table File ID = 29
Table Type = USER TABLE
Rows read = 3
Rows written = 0
Accesses to overflow record = 0
Is that an expected behavior or a defect?
Thanks,
-Eugene 6 4360
Do you have optimization level 5 or higher?
Cheers
Serge
Serge Rielau <sr*****@ca.ibm.com> wrote in message news:<2t*************@uni-berlin.de>... Do you have optimization level 5 or higher?
Cheers Serge
Hi Serge,
The optimization level was 5 by defualt.
Regards,
-Eugene
My memory is getting hazy.... but try making "I" NOT NULL.. Just a
hunch. Check constraints accept "uncknown", thsi yoru comnstraint is not
fully partitioning.
You do have a NOT NULL where clause, but maybe DB2 doesn't figure that
one out.....
Cheers
Serge
Serge,
NOT NUT specified for T[1,2,3].I doesn't help. Also I tried to change
CHECK from BETWEEN to IN list but that didn't help too.
-Eugene
Serge Rielau <sr*****@ca.ibm.com> wrote in message news:<2t*************@uni-berlin.de>... My memory is getting hazy.... but try making "I" NOT NULL.. Just a hunch. Check constraints accept "uncknown", thsi yoru comnstraint is not fully partitioning. You do have a NOT NULL where clause, but maybe DB2 doesn't figure that one out.....
Cheers Serge
"Eugene" <eu****@profitlogic.com> wrote in message
news:95**************************@posting.google.c om... Serge Rielau <sr*****@ca.ibm.com> wrote in message
news:<2t*************@uni-berlin.de>... Do you have optimization level 5 or higher?
Cheers Serge
Hi Serge,
The optimization level was 5 by defualt.
Regards, -Eugene
Try optimization level 7. I think you need this to get the UNION ALL
optimizations.
--
Matt Emmerton
I tried the optimization level 7 but it doesn't prune too.
-Eugene
"Matt Emmerton" <ma**@gsicomp.on.ca> wrote in message news:<lv********************@rogers.com>... "Eugene" <eu****@profitlogic.com> wrote in message news:95**************************@posting.google.c om... Serge Rielau <sr*****@ca.ibm.com> wrote in message news:<2t*************@uni-berlin.de>... Do you have optimization level 5 or higher?
Cheers Serge
Hi Serge,
The optimization level was 5 by defualt.
Regards, -Eugene
Try optimization level 7. I think you need this to get the UNION ALL optimizations. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: kalamos |
last post by:
This statement fails
update ded_temp a
set a.balance = (select sum(b.ln_amt)
from ded_temp b
where a.cust_no = b.cust_no
and a.ded_type_cd = b.ded_type_cd
and a.chk_no = b.chk_no
group by...
|
by: jtwright |
last post by:
I've got a view that creates a parent child relationship, this view is
used in Analysis Services to create a dimension in a datastore. This
query tends to deadlock after about 10 days of running...
|
by: serge |
last post by:
/*
This is a long post. You can paste the whole message
in the SQL Query Analyzer.
I have a scenario where there are records
with values pointing to wrong records and I need to fix them
using an...
|
by: Vorpal |
last post by:
Here is a small sample of data from a table of about 500 rows
(Using MSSqlserver 2000)
EntryTime Speed Gross Net
------------------ ----- -----
21:09:13.310 0 0 0
21:09:19.370 9000 ...
|
by: _link98 |
last post by:
Problem: getting SQL0181N for queries on nicknames to remote
Union-All-View.
Can't see what I'm doing wrong yet, maybe someone has seen this before.
Environment: UDB ESE 8.1 + FIXPAK 9A, on...
|
by: Paulo Matos |
last post by:
Hi all,
Guess I wish to do some parsing for a calculator which might include
rational numbers.
So I can have integers (sequence of digits possibly started by -) and
rationals (two integers...
|
by: wugon.net |
last post by:
question: db2 LUW V8 UNION ALL with table function month() have bad
query performance
Env:
db2 LUW V8 + FP14
Problem :
We have history data from 2005/01/01 ~ 2007/05/xx in single big...
|
by: oskhan |
last post by:
Hello Everyone,
I have a little different problem and I though anyone might give me any idea that what is going wrong.
I have a view which consists of 3 tables linked by UNION ALL, overall...
|
by: Michel Esber |
last post by:
Hi all,
DB2 V8 LUW FP 15
There is a table T (ID varchar (24), ABC timestamp). ID is PK.
Our application needs to frequently update T with a new value for ABC.
update T set ABC=? where ID...
|
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...
|
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...
|
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...
|
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,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |