cheryl9063
asked on
Order of Select
Curious. If you select one column but not from the table in your from but the table in your join, does that matter? How does the SQL engine handle this? See below
Select
b.Name Id
From appointments a
join names b on a.SomeID=b.SomeID
Where A.SomeID = 5000000
Select
b.Name Id
From appointments a
join names b on a.SomeID=b.SomeID
Where A.SomeID = 5000000
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
such "simple" query both shall run in the same explain plan, hence in the same performance
ASKER
Are you sure? If we have 34,000,000 rows and multiple indexes both would perform the same?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
yes, both would perform the same, normally. as the indexes are "static" (in terms of their existance), the sql engine will first see what indexes are there, which would be the most approriate for the query (checking what you give as input, what it will return as ouput, statistics by the table data and indexes etc, without going into details here), and find for both queries the same explain plan.
please just use the "estimate explain plan" for the 2 queries, it shall show you a graphical display, which should be the same for both. the number of "source records" does not matter.
however, based on server load, if the statistics based on input/ouput data might be very close to some "internal thresholds", your queries might indeed be run differently. but this is very unlikely.
please just use the "estimate explain plan" for the 2 queries, it shall show you a graphical display, which should be the same for both. the number of "source records" does not matter.
however, based on server load, if the statistics based on input/ouput data might be very close to some "internal thresholds", your queries might indeed be run differently. but this is very unlikely.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Select b.Name Id
From appointments a
join names b on a.SomeID=b.SomeID
Select b.Name Id
From names b
join appointments a on a.SomeID=b.SomeID