Author |
Topic |
jooorj
Posting Yak Master
126 Posts |
Posted - 2011-04-25 : 19:32:28
|
JOIN hints can be used in a query to specify the type of JOIN the Query Optimizer is to use for the execution plan. The JOIN options are:•Loop •Merge •Hash what is that means ?What is LEFT OUTER JOIN HASH ?sampleSELECT p.Name, pr.ProductReviewIDFROM Production.Product pLEFT OUTER HASH JOIN Production.ProductReview prON p.ProductID = pr.ProductIDORDER BY ProductReviewID DESC; |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-04-25 : 20:09:04
|
JOIN hints are documented in Books Online, and are not recommended without extensive testing and comparison to non-hinted queries. |
|
|
jooorj
Posting Yak Master
126 Posts |
Posted - 2011-04-26 : 01:29:54
|
"JOIN hints are documented in Books Online" what do you mean ? |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
jooorj
Posting Yak Master
126 Posts |
Posted - 2011-04-26 : 03:56:49
|
Thank you I expected that you do not know the solution :) |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2011-04-26 : 04:08:52
|
I'm quite sure that Tara knows full well what join hints are and what they do. The fact that we're referring you to documentation doesn't mean we don't know. Learning to use the documentation is essential for any DBA or database developer.If, once you're read the documentation, you still have questions, please ask.--Gail ShawSQL Server MVP |
|
|
X002548
Not Just a Number
15586 Posts |
|
jooorj
Posting Yak Master
126 Posts |
Posted - 2011-04-26 : 17:30:20
|
please if you have answer tell me/? |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-04-26 : 17:32:43
|
http://msdn.microsoft.com/en-us/library/ms173815.aspx |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2011-04-26 : 18:33:40
|
Do you know how to spell ingratiatehttp://www.imdb.com/title/tt0107048/quotesPhil: I don't suppose there's any chance of a espresso or cappuccino? Mrs. Lancaster: [confused look] Oh, I don't know... Phil: [turns away, to self] ... how to /spell/ espresso or cappuccino. PLEASE GO TO BOOKS ONLINEStart>All Programs>Microsoft SQL Server 2008 R2 (hopefully)>Documentation and Tutorials>SQL Server Books OnlineIf Not Google Books Onlinehttp://msdn.microsoft.com/en-us/library/ms130214.aspxIn any case, I personally don't recommend any Hints,except in RARE circumstances....and unless this is for a test (being that time of year)...then you should have studiedBOL:quote: The hash join has two inputs: the build input and probe input. The query optimizer assigns these roles so that the smaller of the two inputs is the build input.Hash joins are used for many types of set-matching operations: inner join; left, right, and full outer join; left and right semi-join; intersection; union; and difference. Moreover, a variant of the hash join can do duplicate removal and grouping, such as SUM(salary) GROUP BY department. These modifications use only one input for both the build and probe roles.The following sections describe different types of hash joins: in-memory hash join, grace hash join, and recursive hash join.In-Memory Hash JoinThe hash join first scans or computes the entire build input and then builds a hash table in memory. Each row is inserted into a hash bucket depending on the hash value computed for the hash key. If the entire build input is smaller than the available memory, all rows can be inserted into the hash table. This build phase is followed by the probe phase. The entire probe input is scanned or computed one row at a time, and for each probe row, the hash key's value is computed, the corresponding hash bucket is scanned, and the matches are produced.Grace Hash JoinIf the build input does not fit in memory, a hash join proceeds in several steps. This is known as a grace hash join. Each step has a build phase and probe phase. Initially, the entire build and probe inputs are consumed and partitioned (using a hash function on the hash keys) into multiple files. Using the hash function on the hash keys guarantees that any two joining records must be in the same pair of files. Therefore, the task of joining two large inputs has been reduced to multiple, but smaller, instances of the same tasks. The hash join is then applied to each pair of partitioned files.Recursive Hash JoinIf the build input is so large that inputs for a standard external merge would require multiple merge levels, multiple partitioning steps and multiple partitioning levels are required. If only some of the partitions are large, additional partitioning steps are used for only those specific partitions. In order to make all partitioning steps as fast as possible, large, asynchronous I/O operations are used so that a single thread can keep multiple disk drives busy.Note: If the build input is only slightly larger than the available memory, elements of in-memory hash join and grace hash join are combined in a single step, producing a hybrid hash join. It is not always possible during optimization to determine which hash join is used. Therefore, SQL Server starts by using an in-memory hash join and gradually transitions to grace hash join, and recursive hash join, depending on the size of the build input.If the optimizer anticipates wrongly which of the two inputs is smaller and, therefore, should have been the build input, the build and probe roles are reversed dynamically. The hash join makes sure that it uses the smaller overflow file as build input. This technique is called role reversal. Role reversal occurs inside the hash join after at least one spill to the disk.Note: Role reversal occurs independent of any query hints or structure. Role reversal does not display in your query plan; when it occurs, it is transparent to the user. Hash BailoutThe term hash bailout is sometimes used to describe grace hash joins or recursive hash joins.Note: Recursive hash joins or hash bailouts cause reduced performance in your server. If you see many Hash Warning events in a trace, update statistics on the columns that are being joined.
Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxWant to help yourself?http://msdn.microsoft.com/en-us/library/ms130214.aspxhttp://weblogs.sqlteam.com/brettk/http://brettkaiser.blogspot.com/ |
|
|
Jahanzaib
Posting Yak Master
115 Posts |
Posted - 2011-04-27 : 10:59:44
|
I think you are asking Query hints,There are 3 types of join option available for query optimizer to use it1-MERGE2-HASH3-LOOPdefine OPTION in the end of query OPTION (MERGE JOIN)Example SELECT * FROM tab1 AS aINNER JOIN tab2 AS b ON a.cx= b.cx WHERE cy = 5OPTION (MERGE JOIN)For further clarification visit on this linkhttp://aureus-salah.com/2011/02/25/sql-server-query-hints/Regards,Syed Jahanzaib Bin HassanMCTS,MCITP,OCA,OCP,OCE,SCJP,IBMCDBAMy Blogwww.aureus-salah.com |
|
|
|