473,385 Members | 1,927 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,385 software developers and data experts.

How to force the join order ?

Hi,

1) Is it possible to force the join order of the tables in a query
(similar to "hints" in Sybase, etc) ?
For Example, I am joining 3 tables - A,B & C in my SELECT stmt, and I
would like to force the optimizer to always join A & B first and the
results, with C.

2) We have a number of queries in which more than 20 tables have been
joined. Is 20 too big a number ? Is there an optimal number of tables
that we can join ?

Thanks in advance
- Murty

Oct 16 '06 #1
2 3871
Veeru71 wrote:
Hi,

1) Is it possible to force the join order of the tables in a query
(similar to "hints" in Sybase, etc) ?
For Example, I am joining 3 tables - A,B & C in my SELECT stmt, and I
would like to force the optimizer to always join A & B first and the
results, with C.
Take a look at optimizer profiles. Should also for against DB2 V8.2
http://tinyurl.com/ylpyjt
DB2 for zOS has similar support, but I don't have the docs handy.
2) We have a number of queries in which more than 20 tables have been
joined. Is 20 too big a number ? Is there an optimal number of tables
that we can join ?
It depends on teh quality of your statistics.
As joins stack up cardinality estimates for the intermediate result sets
get more and more out of wack.
Make suer you have distribution statistics on the tables as well as
column group stats for correlated columns which are used in
join-predicates (such as maker = 'Honda' AND model = 'Accord').
Alse take a look at statistical views: http://tinyurl.com/ye9sa2

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Oct 16 '06 #2
Serge Rielau wrote:
Alse take a look at statistical views: http://tinyurl.com/ye9sa2
Very interesting. Are statistical views only available in V9, or are
they also available in some flavor of V8?

-Chris

Oct 16 '06 #3

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

Similar topics

2
by: Pierre Fortin | last post by:
This quest for understanding started very innocently... A simple error on my part, passing on args as "args" instead of "*args" to os.path.join() led me to wonder why an error wasn't raised... ...
0
by: B. Fongo | last post by:
I learned MySQL last year without putting it into action; that is why I face trouble in formulating my queries. Were it a test, then you would have passed it, because your queries did help me...
2
by: Bruce Duncan | last post by:
I'm a bit new to MySQL (know MS SQL well...and that may be the problem...getting the syntax confused) and I'm having a join problem...can anyone offer some help? Here's my problem: I have table1...
6
by: tracy | last post by:
I have a complex query (16 table join) that until five days ago took 30 sec to run. It now takes eight hours. I restored a backup of the database from five days ago and the query plans are...
12
by: Phil Powell | last post by:
<cfquery name="getAll" datasource="#request.dsn#"> SELECT U.userID, U.fname, U.lname, U.phone, U.lastLoggedIn, U.choiceId, U.experience, T.label AS teamLabel, R.label AS roleLabel FROM User U...
4
by: Bob Quintal | last post by:
Have two tables linked from SQL server into Access '97, one containing an autonumber primary key and the second table has a text field populated with cstr(). I can create a query that contains...
52
by: MP | last post by:
Hi trying to begin to learn database using vb6, ado/adox, mdb format, sql (not using access...just mdb format via ado) i need to group the values of multiple fields - get their possible...
7
by: Dave | last post by:
I have a database with 3 tables, one for nominees, one for voters and one for votes. I used the following syntax SELECT `tblnominees`.`fldNominee`, Count(`tblvotes`.`fldVote`) AS...
5
code green
by: code green | last post by:
I cannot get the following query correct. Please can somebody put me right SELECT , FROM INNER JOIN ON . = . INNER JOIN ON . = . INNER JOIN invoice ON . = . INNER JOIN deliver ON . =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.