473,405 Members | 2,421 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,405 software developers and data experts.

Sorting

Ian
Hi,
can someone tell me why this join perform sort(saw it in access plan). Is
there a book that explains db2 query tuning, especially this kind of stuff.

SELECT
C.*,
O.*
FROM
crm.CUSTOMER C, crm.ORGANISATION O
WHERE
C.ID = O.ID
Thanks,
Ian
Nov 12 '05 #1
6 4273

"Ian" <ia***************@yahoo.com> wrote in message
news:cr***************************@40tude.net...
Hi,
can someone tell me why this join perform sort(saw it in access plan). Is
there a book that explains db2 query tuning, especially this kind of stuff.
SELECT
C.*,
O.*
FROM
crm.CUSTOMER C, crm.ORGANISATION O
WHERE
C.ID = O.ID

A join can require a sort of one or both tables depending on what indexes
are available.

You haven't specified your version of DB2 or your platform so I can't point
you to a specific URL that will answer your question about query tuning.
However, you probably want the Administration Guide for your
version/platform. All of the DB2 manuals are available online at the IBM
website, http://www.ibm.com.

Rhino
Nov 12 '05 #2
Ian
On Tue, 31 Aug 2004 08:31:58 -0400, Rhino wrote:
"Ian" <ia***************@yahoo.com> wrote in message
news:cr***************************@40tude.net...
Hi,
can someone tell me why this join perform sort(saw it in access plan). Is
there a book that explains db2 query tuning, especially this kind of

stuff.

SELECT
C.*,
O.*
FROM
crm.CUSTOMER C, crm.ORGANISATION O
WHERE
C.ID = O.ID

A join can require a sort of one or both tables depending on what indexes
are available.

You haven't specified your version of DB2 or your platform so I can't point
you to a specific URL that will answer your question about query tuning.
However, you probably want the Administration Guide for your
version/platform. All of the DB2 manuals are available online at the IBM
website, http://www.ibm.com.

Rhino


I have indexes on both ID's. Is there a way to avoid this sort?

I've already downloaded DB2 manuals for v7.2, but haven't found this sort
of info.

Thanks.
Nov 12 '05 #3
AK
Ian,
you might want to google on "merge join"
Nov 12 '05 #4

"Ian" <ia***************@yahoo.com> wrote in message
news:1k******************************@40tude.net.. .
On Tue, 31 Aug 2004 08:31:58 -0400, Rhino wrote:
"Ian" <ia***************@yahoo.com> wrote in message
news:cr***************************@40tude.net...
Hi,
can someone tell me why this join perform sort(saw it in access plan). Is there a book that explains db2 query tuning, especially this kind of

stuff.

SELECT
C.*,
O.*
FROM
crm.CUSTOMER C, crm.ORGANISATION O
WHERE
C.ID = O.ID

A join can require a sort of one or both tables depending on what indexes are available.

You haven't specified your version of DB2 or your platform so I can't point you to a specific URL that will answer your question about query tuning.
However, you probably want the Administration Guide for your
version/platform. All of the DB2 manuals are available online at the IBM
website, http://www.ibm.com.

Rhino


I have indexes on both ID's. Is there a way to avoid this sort?

I've already downloaded DB2 manuals for v7.2, but haven't found this sort
of info.

I assume you mean DB2 V7.2 for Windows/Linux/Unix. I have the same manuals
and found a discussion that might answer your question via the search engine
in the IBM DB2/Information application. I searched on "join concepts" and
found several hits. The one that might answer your questions is in the
Administration Guide in a page entitled "Data Access Concepts and
Optimization". Near the very top of that page, is a internal link for "Join
Concepts". If you click on it, you go much further down that same long page
and come to a discussion of the three DB2 Join types: nested loop, merge
join and hash join. This may help you. Or not.

It isn't clear from your note whether you are getting one sort or two so I
don't know if you are getting a merge join or a hash join. That would be a
useful thing to know if you can determine that information. Do you know how
to use any of the forms of Explain? Any form of Explain should tell you
which type of join you're doing. Explain is described in detail in the
Administration Guide, Chapter 26.

I suggest that you do an Explain first to determine exactly which kind of
join you are getting. Then read the Join Concepts section for some insight
into how that type of join works and when/why the Optimizer chooses it. If
that doesn't answer your question, please post again with at least the join
type and maybe someone here can help you further.

Rhino
Nov 12 '05 #5
AK
>
I have indexes on both ID's. Is there a way to avoid this sort?


OPTIMIZE FOR FIRST xx ROWS clause might get rid of the sort.
However, comparing real execution costs might indicate that the plan
involving sort is actually better.

Another common way to avoid sorts is to reorganize the child table
(and maybe also the parent one) on the FK / PK indexes
Nov 12 '05 #6
Ian
On Tue, 31 Aug 2004 13:12:48 -0400, Rhino wrote:
"Ian" <ia***************@yahoo.com> wrote in message
news:1k******************************@40tude.net.. .
On Tue, 31 Aug 2004 08:31:58 -0400, Rhino wrote:
"Ian" <ia***************@yahoo.com> wrote in message
news:cr***************************@40tude.net...
Hi,
can someone tell me why this join perform sort(saw it in access plan). Is there a book that explains db2 query tuning, especially this kind of
stuff.

SELECT
C.*,
O.*
FROM
crm.CUSTOMER C, crm.ORGANISATION O
WHERE
C.ID = O.ID
A join can require a sort of one or both tables depending on what indexes are available.


I have indexes on both ID's. Is there a way to avoid this sort?

I've already downloaded DB2 manuals for v7.2, but haven't found this sort
of info.

I assume you mean DB2 V7.2 for Windows/Linux/Unix. I have the same manuals
and found a discussion that might answer your question via the search engine
in the IBM DB2/Information application. I searched on "join concepts" and


Rhino, AK thank you both. I run dynexpln and found that query is using
merge join. I also reorganized both tables but sort is stil here.

I will read those chapters you suggested and try to solve this.
This is output from dynexpln:

------------------------------------------------------
Estimated Cost = 128906
Estimated Cardinality = 159397

Access Table Name = CRM.ORGANISATION ID = 2,97
| #Columns = 7
| Relation Scan
| | Prefetch: Eligible
| Lock Intents
| | Table: Intent Share
| | Row : Next Key Share
| Insert Into Sorted Temp Table ID = t1
| | #Columns = 7
| | #Sort Key Columns = 1
| | | Key 1: ID (Ascending)
| | Sortheap Allocation Parameters:
| | | #Rows = 159397
| | | Row Width = 68
| | Piped
Sorted Temp Table Completion ID = t1
Access Temp Table ID = t1
| #Columns = 7
| Relation Scan
| | Prefetch: Eligible
Merge Join
| Early Out: Single Match Per Outer Row
| Access Table Name = CRM.CUSTOMER ID = 2,74
| | #Columns = 17
| | Index Scan: Name = CRM.SQL040720111132250 ID = 1
| | | Index Columns:
| | | | 1: ID (Ascending)
| | | #Key Columns = 0
| | | | Start Key: Beginning of Index
| | | | Stop Key: End of Index
| | | Data Prefetch: Eligible 0
| | | Index Prefetch: None
| | Lock Intents
| | | Table: Intent Share
| | | Row : Next Key Share
Return Data to Application
| #Columns = 24
---------------------------------------------------------
Thanks, Ian

Nov 12 '05 #7

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

Similar topics

4
by: dont bother | last post by:
This is really driving me crazy. I have a dictionary feature_vectors{}. I try to sort its keys using #apply sorting on feature_vectors sorted_feature_vector=feature_vectors.keys()...
0
by: ck388 | last post by:
For some reason when I enable the callback feature of the gridview I still get a page refresh, that is it seems like there is a postback that occurs, not a callback which is just supposed to update...
7
by: Federico G. Babelis | last post by:
Hi All: I have this line of code, but the syntax check in VB.NET 2003 and also in VB.NET 2005 Beta 2 shows as unknown: Dim local4 As Byte Fixed(local4 = AddressOf dest(offset)) ...
19
by: Owen T. Soroke | last post by:
Using VB.NET I have a ListView with several columns. Two columns contain integer values, while the remaining contain string values. I am confused as to how I would provide functionality to...
10
by: Sjaakie | last post by:
Hi, I'm, what it turns out to be, fooling around with 3-tier design. At several websites people get really enthusiastic about using custom dataobjects instead of datasets/-tables. While trying to...
4
by: Ambica Jain | last post by:
Hi, I want custom sorting on some of the columns in the datagrid. And i am able to do the same by overriding MouseDown event. However, i need to rebind my datatable to reflect the changes in...
7
by: Kamal | last post by:
Hello all, I have a very simple html table with collapsible rows and sorting capabilities. The collapsible row is hidden with css rule (display:none). When one clicks in the left of the...
1
KevinADC
by: KevinADC | last post by:
Introduction In part one we discussed the default sort function. In part two we will discuss more advanced techniques you can use to sort data. Some of the techniques might introduce unfamiliar...
5
by: lemlimlee | last post by:
hello, this is the task i need to do: For this task, you are to develop a Java program that allows a user to search or sort an array of numbers using an algorithm that the user chooses. The...
5
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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
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.