Let's say we have a database of Birthday Clowns that contains a geography column containing the binary representation of a Point where each clown is located (generated from the latitude and longitude of the clown's home address). There's a geo-index on the geography column.
The CEO of a major international software company sends us a CSV file of all of their employees in the US, and their street addresses, including latitude and longitude; we have to generate a report that says for each employee how many birthday clowns are within 15 miles.
Our where condition could look like this:
where
(ClownLocationInBinary).STDistance( geography::Point(EES.lat, EES.lng, 4326) ) < radius
or like this:
where
geography::Point(EES.lat, EES.lng, 4326).STDistance(ClownLocationInBinary) < radius
Will both where-clauses take advantage of the index we created on our BirthdayClowns table? Or does one of them use it but not the other? If so, which is which?