Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 What are the benefits of a bushy join?

Author  Topic 

MuadDBA

628 Posts

Posted - 2009-11-16 : 12:41:37
At PASS, I had the pleasure of attending most of a session by Itzik Ben-Gan, who always has some great tips and tricks for using T-SQL. One of his tips was how to force SQL Server to use a bushy join plan, something the optimizer is capable of but will never choose because it always picks "good enough" plans, and bushy join optimization requires more analysis.

Unfortunately, I had to leave that session before it completed, and I did not see if he gave any tips on when a bushy join is a good thing, and when it might be bad. Google is not helping me out either, so if anyone canlink me to, or provide a brief primer on, bushy joins, I would appreciate it.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-11-16 : 12:58:47
I've never even heard of "bushy" joins.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

MuadDBA

628 Posts

Posted - 2009-11-16 : 13:03:06
Well if the PASS recordings were posted I would link you to one, but they basically allow you to directly join the product of a join to another join product....it would be easier to explain using a picture, but they have a brief explanation of it in wikipedia. Here it is:

One can classify query-plans involving joins as follows:[4]

left-deep
using a base table (rather than another join) as the inner operand of each join in the plan
right-deep
using a base table as the outer operand of each join in the plan
bushy
neither left-deep nor right-deep; both inputs to a join may themselves result from joins
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2009-11-16 : 13:07:45
Is this a joke?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2009-11-16 : 13:09:53
No Bushy

http://www.solidq.com/insidetsql/index.htm

Or on Google either

Was this after the hemp seminar?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-11-16 : 13:15:02
I'm still a little unclear, but it sounds like it may involve derived tables.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-11-16 : 13:18:06
There is mention of "bushy" here:
http://en.wikipedia.org/wiki/Query_optimizer

Be One with the Optimizer
TG
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2009-11-16 : 13:21:21
I'm sure we can find lots of references to bushy



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-11-16 : 13:46:28
quote:
Originally posted by X002548

I'm sure we can find lots of references to bushy



you mean like this?


Be One with the Optimizer
TG
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2009-11-16 : 13:48:35
I am NOT going to open that here

But it's funny, even the subject line

Google that

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

MuadDBA

628 Posts

Posted - 2009-11-16 : 13:53:15
This is not a joke, though I know I wrote a funny topic title. Even the "left deep, right deep" stuff has me chuckling, but it is dead serious. Perhaps I am going to have to e-mail Itzik himself?

Here's a link to the code on Itzik's site that includes bushy joins:

http://www.solidq.com/insidetsql/books/source_code/T-SQL%20Tips%20&%20Tricks.zip

Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-11-16 : 13:55:00
In my experience, bushy joins look like a great idea at first, then they get a bit messy (although fun), evenutally the constraint goes in, then out, then in, evenutally it looses interest and never calls the tuple back.
Go to Top of Page

MuadDBA

628 Posts

Posted - 2009-11-16 : 14:00:37
quote:
Originally posted by tkizer

I'm still a little unclear, but it sounds like it may involve derived tables.

Tara Kizer




Nope, no derived tables. Just a different join type that no one sees because the optimizer will never choose it unles forced. Yes, tee, hee, forcing a bushy join is not a good idea...ahem. The optimizer only "optimizes" until it finds a plan that is "good enough" it does not evaluate all options in order to save time. Therefore it never gets to the level of evaluating this more advanced style of join.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2009-11-16 : 14:16:57
quote:
Originally posted by crazyjoe

This is not a joke, though I know I wrote a funny topic title. Even the "left deep, right deep" stuff has me chuckling, but it is dead serious. Perhaps I am going to have to e-mail Itzik himself?

Here's a link to the code on Itzik's site that includes bushy joins:

http://www.solidq.com/insidetsql/books/source_code/T-SQL%20Tips%20&%20Tricks.zip





Already did that and gave him a link to this post



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2009-11-16 : 17:25:44
Here are shots of the example plans:

Non-bushy: http://imgur.com/Ht7hW.png
Bushy: http://imgur.com/fGFWR.png

Based on the query hint and the parentheses, the bushy join makes the optimizer work on 2 joins at a time, instead of 1 at a time. The plan shows how that would parallelize more easily than the non-hinted version. This is mentioned in the Wikipedia article.
Go to Top of Page

MuadDBA

628 Posts

Posted - 2009-11-16 : 20:02:53
Thanks for the images, Rob. One thing to note, however, is that the parentheses are not strictly necessary. They make it easier to comprehend, but if structured correctly, no parentheses need to be used.
Go to Top of Page

TallCowboy0614
Starting Member

17 Posts

Posted - 2009-12-01 : 14:02:08
I think the Brazilian plan renders Bushy Joins obsolete.

_________________________________
aka "Paul"
Non est ei similis.

"He's not the Messiah. He's a very naughty boy!" - Brian's mum
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2009-12-02 : 12:53:36
quote:
Originally posted by TallCowboy0614

I think the Brazilian plan renders Bushy Joins obsolete.

_________________________________
aka "Paul"
Non est ei similis.

"He's not the Messiah. He's a very naughty boy!" - Brian's mum



Unless it's a LEFT BUSHY JOIN



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2009-12-02 : 13:26:37
I prefer the old school +1 post count pumper myself

http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx
How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page
   

- Advertisement -