473,473 Members | 2,025 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Functionally equivalent exception Join

Does DB2 UDB Supports Exception Join? I think 'No'. Hence I used the
following method to find out an functioanally equivalent exception join
select * from tab1
where not exists
(
select col1 from tab2 where tab1.col1 != col1
)

I have indexes on col1 on both tables and statistics are updated but
still it takes some to execute this query. tab1 has 7 Million rows and
tab2 has 10,000 rows.

Any suggestions to improve the performance of this query?

Thanks,
db2udbgirl.

Apr 4 '06 #1
3 3823
Here is the access plan
Access Plan:
-----------
Total Cost: 4.99386e+06
Query Degree: 1

Rows
RETURN
( 1)
Cost
I/O
|
1
DTQ
( 2)
4.99386e+06
33855.8
|
1
GRPBY
( 3)
4.99386e+06
33855.8
|
1.64536e+07
NLJOIN
( 4)
4.99211e+06
33855.8
/---+---\
3.05148e+06 5.392
IXSCAN FILTER
( 5) ( 6)
62147.5 105.186
33847.8 8
| |
3.05148e+06 134.8
INDEX: CARDP1IN TBSCAN
I2 ( 7)
105.13
8
|
134.8
SORT
( 8)
105.115
8
|
1348
IXSCAN
( 9)
104.104
8
|
1349
INDEX: CARDP1IN
I1

Apr 4 '06 #2
db2udbgirl wrote:
Does DB2 UDB Supports Exception Join? I think 'No'. Hence I used the
following method to find out an functioanally equivalent exception join
select * from tab1
where not exists
(
select col1 from tab2 where tab1.col1 != col1
)


Have you tried an ANSI outer join with a post-join filter:

select tab1.*
from tab1
left join tab2
on tab1.col1 = tab2.col1
where tab2.col1 is null;

Works in IDS, don't see why DB2 shouldn't support it.

Art S. Kagel
Apr 4 '06 #3
> select * from tab1
where not exists
(
select col1 from tab2 where tab1.col1 != col1
)

If this statement returns exactly your required result, I feel
something interesting.
Because, if tab2 have more than two rows with different values of col1,
this query always returns no row of tab1.
If col1 of tab2 have only one value, this query returned rows which are
tab1.col1 = tab2.col1.
And, tab2 is empty, it returns all rows of tab1.

So, following example would be returned same result.
SELECT tab1.*
FROM tab1
LEFT OUTER JOIN
tab2
ON tab1.col1 = tab2.col1
WHERE (SELECT COUNT(DISTINCT col1) FROM tab2) = 1
AND tab2.col1 IS NOT NULL
OR (SELECT COUNT(col1) FROM tab2) = 0;

Apr 5 '06 #4

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

Similar topics

3
by: Peter L. Buschman | last post by:
I'm trying to think in Python, but am stumped here... What is the equivalent for the following if you are dealing with a tuple of non-strings? >>> import string >>> foo = ( '1', '2', '3' )...
3
by: Greg Yasko | last post by:
Hi. Does anyone know if there's an equivalent of Perl's file::find module in Python? It traverses a directory. I've googled extensively and checked this newsgroup and can't find anything like it...
1
by: Mike Brown | last post by:
I thought I was being pretty clever with my first attempt at using generators, but I seem to be missing some crucial concept, for even though this seems to work as intended, the text of the...
1
by: JBBHF | last post by:
Hi i'm working on a web project, and i would like to make my oracle query work in mysql. select match.numero "nummatch", to_char(match.datematch, 'yyyy-MM-dd') "datematch", p1.numjoueur "j1",...
7
by: KingGreg | last post by:
All, Oracle 9i provides a "USING" clause option for inner joins, that allows me to say: SELECT * FROM TBL1 JOIN TBL2 USING KeyColumn assuming KeyColumn is in both TBL1 and TBL2. This is...
4
by: PASQUALE | last post by:
Hi I have a question: do the both statements below give the same result? If yes then does somebody know something about preformance differencies using these joins? SELECT A.* FROM Table1 A...
9
by: Frawls | last post by:
Hi I Am am having problems with a stored Procedure that i wrote. Basically whats happening is that the Stored procedure Runs fine when i EXECUTE it in SQL Query analyzer. But when i debug...
4
by: Newbie19 | last post by:
I am creating a query statement where the customer is only concerned with one of the status to have a filter date on them. The rest of the status types he wants to see all no matter what the date of...
22
by: Kurien Mathew | last post by:
Hello, Any suggestions on a good python equivalent for the following C code: while (loopCondition) { if (condition1) goto next; if (condition2) goto next;
0
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,...
0
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...
0
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,...
1
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...
0
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...
0
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
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...

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.