473,785 Members | 2,266 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DB2 "ALL" subquery strategy

Does DB2 process "ALL" subquery by "nested iteration" strategy, or
using its own special algorithm?

For example, assume r(A, B, C) and s(D, E, F) are two relations,
consider the following query:
Q1: select r.*
from r
where r.A> 5 and
r.C > all (select s.D
from s
where r.B = s.E and s.F<10)

We are planning to unnest this query first by performing outer join and
then process the intermediate result by our approach:
Q2: select r1.*, s1.*
from (select r.*
from r
where r.A > 5) r1
left outer join
(select s.*
from s
where s.F<10) s1
on r.B = s.E

If DB2 evaluate query Q1 by "nested iteration" approach, query Q2
should perform faster than Q1.
However, when I ran them in DB2, Q1 is a little bit faster than Q2. So
I think DB2 has its own algorithm to evaluate "ALL" subquery, is it
true?
thanks
Nov 12 '05 #1
1 7358
If you are talking about db2 udb for LUW, you can check the rewirte part
from the output of db2exfmt utility.

"LazyAnt" <so***********@ hotmail.com> wrote in message
news:f6******** *************** ***@posting.goo gle.com...
Does DB2 process "ALL" subquery by "nested iteration" strategy, or
using its own special algorithm?

For example, assume r(A, B, C) and s(D, E, F) are two relations,
consider the following query:
Q1: select r.*
from r
where r.A> 5 and
r.C > all (select s.D
from s
where r.B = s.E and s.F<10)

We are planning to unnest this query first by performing outer join and
then process the intermediate result by our approach:
Q2: select r1.*, s1.*
from (select r.*
from r
where r.A > 5) r1
left outer join
(select s.*
from s
where s.F<10) s1
on r.B = s.E

If DB2 evaluate query Q1 by "nested iteration" approach, query Q2
should perform faster than Q1.
However, when I ran them in DB2, Q1 is a little bit faster than Q2. So
I think DB2 has its own algorithm to evaluate "ALL" subquery, is it
true?
thanks

Nov 12 '05 #2

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

Similar topics

10
12843
by: KENNY L. CHEN | last post by:
Dear experts, I have two tables in my Oracle 8i database: TEST (COL1,COl2,REC_NO) and TEST1 (COL1,COL2,REC_NO). Both tables are unique-indexed on (COL1,COL2,REC_NO). I think the following SQL commands will return the same result but one of my friends don't think so. He said "QUERY 1" will return 1 unsorted record (ROWNUM < 2 ) first then sort the result (ORDER BY COL1 ASC,
3
2459
by: Adam Toline | last post by:
In reference to the following: http://www.bellecose.com/form.htm At the top of each column there is a box for "All". When one is checked I need to check all of (and only) those boxes underneath. Now, the rub here is that every checkbox on the page (except the "All"s)
4
7193
by: meganrobertson22 | last post by:
Hi Everyone- I have a question about how to add and then use the "All" selection in a combo box. I am trying to figure out how to: (1) add "All" as a selection to a combo box and then (2) how to use the selection "All" as criteria for a field in a query, which is used to generate data for a report.
3
4047
by: google | last post by:
This is something I've done plenty of times in '97, but I can't seem to get it to work correctly in Access 2003. Say, for example, I have a form with an unbound combobox, the data source is a table of customers, first column is the key field, which is hidden with a 0" width, and the second column is the customer name. The SQL is a union query that also inserts Null in the first column, and "All" in the second column. That combobox gets...
2
5361
by: Murphy | last post by:
Our website contains subdirectories for each subsidiary company, each company has it's own look and feel to the pages in their subdirectory although they are all part of the main website. The code below in the Web.Config file defines the authentication as forms and the aspx file required for login if the user is unauthenticated... this works well for the root level company web pages however when a user viewing the website of SubCompanyA...
4
4142
by: google | last post by:
Hi Hope someone can help me with this - have been staring at this problem all day, and with the cold I've got, just don't seem to be able to figure it out! I've got two tables, here with some test data - sorry, can't create DDL as I'm at home & can't access the server :-( TABLE 1: Application_Intermediary
2
5870
by: bhdvir | last post by:
Does anybody have any advice on selecting all records within a iif-statement? I have a form in which one has to state if all projects or just a selection of projects are to be used for a query. If "all projects" are required the query should show all records. In the example below the iif-statement should select all projects or just "projectnumber 2". I tried the following as criteria but none is working:
2
2362
by: getmeidea | last post by:
Hi all, String x = "\\"; This string will have the value \. Now for any string contains \, i need to replace with \\. But when i use x = x.replaceAll("\\", "\\\\"); I am getting runtime exception.
0
9489
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
10162
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
10100
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
9959
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
8988
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
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5396
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5528
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4061
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 we have to send another system

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.