By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,275 Members | 1,545 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,275 IT Pros & Developers. It's quick & easy.

How to force the join order ?

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.