473,397 Members | 1,985 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

How Can Inclusion/Exclusion of Columns Affect Number Rows Returned?

I have a situation that I can't explain. Boiled down to its essence, I
have a query of the form

SELECT A.COL1, A.COL2, B.COL1
FROM A
LEFT JOIN B ON A.KEY = B.KEY

This query produces 5383 rows of output. Because B.COL1 was defined as
VARCHAR(2000), it was making my ouput file too hard to browse so I
eliminated it from the select clause.

SELECT A.COL1, A.COL2
FROM A
LEFT JOIN B ON A.KEY = B.KEY

Now I get only 4459 rows returned. I am confused. I thought the joins
(and any subsequent filtering) would determine the number of rows.

What am I missing here?

Platform is AIX 4.3 + DB2 7.2 FP10.

Thanks,
Evan

Jun 23 '06 #1
4 1523
esmith2112 wrote:
I have a situation that I can't explain. Boiled down to its essence, I
have a query of the form

SELECT A.COL1, A.COL2, B.COL1
FROM A
LEFT JOIN B ON A.KEY = B.KEY

This query produces 5383 rows of output. Because B.COL1 was defined as
VARCHAR(2000), it was making my ouput file too hard to browse so I
eliminated it from the select clause.

SELECT A.COL1, A.COL2
FROM A
LEFT JOIN B ON A.KEY = B.KEY

Now I get only 4459 rows returned. I am confused. I thought the joins
(and any subsequent filtering) would determine the number of rows.

What am I missing here?

Platform is AIX 4.3 + DB2 7.2 FP10.

DB2 V7? Ehem, and and outdated fixpack at that...
Anyway, the only explanation I have which does not involve a bug could
be that you have an RI relationship between the two keys and it has been
corrupted because SET INTEGRITY as run using the UNCHECKED option.
If you have such an RI, perform SET INTEGRITY to verify your data is the
way DB2 thinks it is.
I'm basing my assumption on the fact that DB2 has dropped the join
assuming it is key preserving. And that.. was wrong. There WERE
duplicate B.KEYs

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Jun 24 '06 #2
Serge Rielau wrote:

Platform is AIX 4.3 + DB2 7.2 FP10.

DB2 V7? Ehem, and and outdated fixpack at that...
Anyway, the only explanation I have which does not involve a bug could
be that you have an RI relationship between the two keys and it has been
corrupted because SET INTEGRITY as run using the UNCHECKED option.
If you have such an RI, perform SET INTEGRITY to verify your data is the
way DB2 thinks it is.
I'm basing my assumption on the fact that DB2 has dropped the join
assuming it is key preserving. And that.. was wrong. There WERE
duplicate B.KEYs

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab


V7, yes. The road to upgrade has been difficult with ties to legacy
applications that have proven to be upgrade-resistent. With that
said...

The relationship between A to B is one-to-many. There is a FK
relationship in place.

I tried experiementing with SET INTEGRITY. I also dropped all
constraints at one point. Nothing altered the crazy results. I used the
explain facility to generate the plans. The only difference between the
two is that the query that fetches the extra column shows the FETCH in
addition to an IXSCAN. The other has just the IXSCAN.

Being out of support for so long has made us largely self-reliant on
problem solving but this one has our heads spinning. I will continue to
test. Is it possible that higher level FixPak will solve the problem?

Thanks,
Evan

Jun 26 '06 #3
xiva
1
Hi,Evan,

Why not take a look the different records between these 2 result set?
I'm interested about the issue, if the data are not sensitive, can you send me the ixf format of these 2 tables to my e-mail box? I will import them into my UDB 8.2 PE environment and have a test, and then send the result back to you. :) My mail box is: ibmudb@163.com.

Thanks,
xiva
Jun 26 '06 #4
esmith2112 wrote:
Serge Rielau wrote:
Platform is AIX 4.3 + DB2 7.2 FP10.

DB2 V7? Ehem, and and outdated fixpack at that...
Anyway, the only explanation I have which does not involve a bug could
be that you have an RI relationship between the two keys and it has been
corrupted because SET INTEGRITY as run using the UNCHECKED option.
If you have such an RI, perform SET INTEGRITY to verify your data is the
way DB2 thinks it is.
I'm basing my assumption on the fact that DB2 has dropped the join
assuming it is key preserving. And that.. was wrong. There WERE
duplicate B.KEYs

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab


V7, yes. The road to upgrade has been difficult with ties to legacy
applications that have proven to be upgrade-resistent. With that
said...

The relationship between A to B is one-to-many. There is a FK
relationship in place.

I tried experiementing with SET INTEGRITY. I also dropped all
constraints at one point. Nothing altered the crazy results. I used the
explain facility to generate the plans. The only difference between the
two is that the query that fetches the extra column shows the FETCH in
addition to an IXSCAN. The other has just the IXSCAN.

Being out of support for so long has made us largely self-reliant on
problem solving but this one has our heads spinning. I will continue to
test. Is it possible that higher level FixPak will solve the problem?

Yes, but if it does it should be in the APAR list. If things went as
they should, it should have been flagged as HIPER High Pervasive.
So peruse that list.

Take a look at the explains for the two queries to validate whether the
join partner was dropped.

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Jun 26 '06 #5

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

Similar topics

32
by: Rich | last post by:
I'm sure it sounds kinda nutty to display 200 columns and 500,000 rows of data. But I have been pulling data from a Lotus Notes database into Sql Server for a while now, but Lotus Notes is...
10
by: Lauren Quantrell | last post by:
I have never written a trigger before and now am seeing the light. Is there a way to write a trigger so that if a user changes any column in a single row on one table then the trigger will write...
2
by: Neil Zanella | last post by:
Hello, I would like to know whether having a <table> element with two <tr> elements each containing one <td> elements and two <td> elements, respectively, is legal from the point of view of...
2
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
68
by: Martin Joergensen | last post by:
Hi, I have some files which has the following content: 0 0 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 0 0 0 0 0
5
by: Dave | last post by:
Is there a way to divide a datagrid into "newspaper" style columns so that column 1 would have rows 1-10, column two would have rows 11-20 etc? Thanks, Dave.
4
by: venkatbo | last post by:
Hi folks, I'd like to disable the inclusion of tk graphics lib in my py build. Looked around but couldn't find a clear answer. Which one of the following would I need to use in the configure...
0
by: sysmanint1 | last post by:
I am a total neophyte at Visual Basic but found the following post and reply from Clint concerning a dynamic range. Also, have never "posted" to a discussion I have made a macro that works on...
2
by: =?Utf-8?B?dmFuZGls?= | last post by:
I have a web app that I have been working on for the last couple of weeks trying to solve this problem. One page contains a GridView with four base columns, and an unknown number of columns to be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
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...

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.