Only this week, get the SQL Complete Track of 9 courses in a special prize of $330 $89!
3. Geometry vs. Geography - detailed explanation


Okay. In the previous part, we mentioned that there are two spatial column types: geometry and geography. We also said that geometry is quicker than geography. Let's quickly explain why.

As we all remember from school, the Earth is round. On the other hand, maps are flat. It is impossible to transfer a 3D sphere (Earth) onto a 2D surface (map) without certain distortions. No map projection is therefore ideal. What seems like a straight line on the map is bent in reality, and vice versa.

The greater the area we consider, the greater the error we get. If you take a ruler, measure the distance from San Francisco to Tokyo in a straight line and multiply the result by the map scale, there will be significant error in your measurement (as compared to the real distance). On the other hand, if you repeated the same procedure to calculate a distance within a single city, the error will be negligible.

Actual Distance

Calculating exact distances and areas on the Earth is possible but much more complicated. Those exact calculations, which take into account the fact that the Earth is round, can be performed using the geography type. We'll take a look at this at the end of the course. Most of the time, however, we'll use the geometry type, which focuses on 2D calculations. It's less accurate, but much, much quicker and more frequently used.


Click Next exercise to continue.