[b]The correct answer is 1 INNER JOIN is used. When the database engine executes the SELECT query to return all rows that have an email address of 'email@example.com' the following steps take place:
1. There is an Index Seek on the IX_EmailAddress non clustered index - this searches for the 'firstname.lastname@example.org' email address. When the email address is found in the index, its QOTDID value will be used in STEP 2 - The value for EmailAddress is returned by this step.
2. Next there is a clustered index seek on the IX_QOTDID index looking for the QOTDID value which was found in STEP 1. - The value for Title, DateSubmitted and Age are returned by this step.
3. Then the output of the index seek (STEP 1) is joined with the output of the clustered index seek (STEP 2) and the data is returned via the SELECT statement - thus returning the row of data that contains an EmailAddress of 'email@example.com' :
Is there really a JOIN happening while a select is applied with a column with Non-Clustered index from a table containing Clustered index?
I believe its traversing happening between the clustered and Non-Clustered indexes to find the actual row.
Let me explain it with using the concept of Nonclustered Index:
In a nonclustered index, the leaf level does not contain all the data. In addition to the key values, each index row in the leaf level (the lowest level of the tree) contains a bookmark that tells SQL Server where to find the data row corresponding to the key in the index.
A bookmark can take one of two forms. If the table has a clustered index, the bookmark is the clustered index key for the corresponding data row. If the table is a heap (in other words, it has no clustered index), the bookmark is a row identifier (RID), which is an actual row locator in the form File#
In this case, the bookmark (or pointer) contains the Clustered Index key. So after getting the clustered index key what I believe is it searches the row using this key (here it is QOTID column).
So I believe join is not happening.
Correct me if I'm wrong.
So please SHout :-)