SQL Perfromance Reference: Joins vs. Seperate Queries
I need to find the reference / reasoning for the following argument:
For instance, consider this query:
SELECT
Users.Name,
ProductLicenses.StartDate,
ProductLicenses.EndDate
FROM Users JOIN ProductLicenses
ON Users.Id = ProductLicenses.UserId
WHERE Users.Id = @UserId
Versus this:
SELECT
Users.Name
FROM Users WHERE Users.Id = @UserId
And then this:
SELECT
ProductLicenses.StartDate,
ProductLicenses.EndDate
FROM ProductLicenses
WHERE ProductLicenses.UserId = @UserId
I know that the first one should be more efficent, but I can't find out the documentation for it. Server round trips is one consideration (although it can be mitigated with multiply result sets), but the concern here is the performance of the server only.
Note: I'm talking here about 2 - 4 tables joins, top, properly indexed.
Comments
Comment preview