473,806 Members | 2,321 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Branch elimination for a query on a UNION ALL View does not work as expected

Hi all,

I'm investigating partitioned tables using a UNION ALL VIEW and found
the following (see ddl below):
If I create a check constraint like "check (month(tdate) = 1)" DB2
won't do branch elimination for a query like "SELECT * FROM Q1 WHERE
TDATE = '01.01.2004'". Explains shows that all 3 tables are accessed.
But with a a constraint "check (tdate between '01.01.2004' and
'31.01.2004')" DB2 will do branch elimination - means only tab_01 is
accessed.
I tried this with QUERYOPT 5,7 and 9 - same result.
I saw some similar threads for this theme - but no answer (neither
"works as designed" nor "DB2 can't do this at the moment")

Any comments ?

Details:
db2level: DB21085I Instance "DB2" uses "32" bits and DB2 code release
"SQL08020" with level identifier "03010106".
Informational tokens are "DB2 v8.1.7.445", "s040812", "WR21342", and
FixPak "7".

create table tab_01
(tdate date not null
,col1 integer not null
,col2 char(10) not null
) in userspace1;
create table tab_02 like tab_01 in userspace1;
create table tab_03 like tab_01 in userspace1;

alter table tab_01 add constraint tab_01_chk check (month(tdate) = 1);
alter table tab_02 add constraint tab_02_chk check (month(tdate) = 2);
alter table tab_03 add constraint tab_03_chk check (month(tdate) = 3);
create index tab_01_x1 on tab_01 (tdate);
create index tab_02_x1 on tab_02 (tdate);
create index tab_03_x1 on tab_03 (tdate);

create view q1 as
select * from tab_01
union all
select * from tab_02
union all
select * from tab_03
with row movement;

TIA
Joachim
Nov 12 '05 #1
1 2383
Works as designed.
The theorem prover isn't smart enough to know that the intricacies of
month(). Would be an easy thing to detect thsi special case, but there
are lots of special cases out there.. Kind of tough to cover and the
optimizer would become to heavy.

Cheers
Serge
Nov 12 '05 #2

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

Similar topics

1
3766
by: Buttercup | last post by:
I am having alot of trouble with a union query Im trying to create. The bizarre thing is I initially created this query and managed to save it as a view SELECT ID, DepartureDate, City, Country, Region, fkDepartureAirport, CONVERT(MONEY, Price) AS Price, '1' AS Type FROM dbo.vHoliday UNION ALL SELECT ID, ValidTo, DestCity, Country, Region, fkDepartureAirport, Price, '2' AS Type
2
1830
by: Susanne Bandi | last post by:
Hello I've experienced that DB2 unfortunately does not eliminate subselects of a UnionAll-View if the predicate's content is not hardcoded but derived from a base-table with a noncorrelated Subselect. Any plans to enhance this for the future? Any workaround suggestions? Thanks in advance Susanne
4
7222
by: Akinia | last post by:
Hi every body I've a little problem with my query, I can't figure it out. I've three tables: Table A (EmployeNr, Date, Code) Table B (EmployeNr, Date, Code) Which is an historic of Table A Table C (BegD, EndD) I can have all the records in table A that doesn't match in table B but not from the other side.
3
1379
by: SusannaW | last post by:
Hi NG I need to create a query wich shows me several fields of one record in several records - in access97. Well, here's an example: ok, that's my table: UniqeNumber Item1 Item2 Item3
4
1604
by: Mark | last post by:
Hi all, I am currently in the design stages of a database for work. I have come up with a way to get informaion I need using a union query but was wandering what effects this will have on performance. To give you an insight, I am using Access XP The database will be split into FE/BE. FE on local machine, BE on network drive
4
7828
by: spam | last post by:
If I run the following query in Access 2002 then I get the expected result: SELECT * FROM CSVImport UNION SELECT * FROM AssetTemp; I get the contents of both tables with no duplicates. If I add INSERT INTO, then it doesn't work:
7
3318
by: KoliPoki | last post by:
Hello every body. I have a small issue. Problem: I have a table with 4 descriptor columns (type). I need to formulate a query to retrieve a count for each type so I can group by...etc. The view I have works, but doesn't work when I supplement the query with some functions... they just don't like the UNION. The real problem is I can't change any of the udf's or queries, just the view. The view is inner joined back on to the primary...
4
21226
by: MR USER | last post by:
Hello, I made a union query that works perfectly in Access giving me a table that display all my nice records. when I try to retrieve these records in excel by either queriying the database or loading the pivot cash I get problems. In the first case I see onlt "normal queries" and the Union query is not available for me to pick up. In the second case (loading the pivot cash using MS Query) I can select the union query and pick its fields...
5
3850
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 table, we try separate this big table into twelve tables and create a view
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9597
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10618
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10371
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10110
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9187
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.