# How far is the nearest pub?

DevFeed: [How far is the nearest pub?](<https://devfeed.tech/articles/how-far-is-the-nearest-pub-34513.md>)

Original publisher: [Read original article](<https://tapoueh.org/blog/2013/08/how-far-is-the-nearest-pub/>)

Author: Dimitri Fontaine PostgreSQL Major Contributor; Author

Published: 2013-08-05T06:11:00Z

Content type: tutorial

Language: en

Sources: [Dimitri Fontaine](<https://devfeed.tech/sources/dimitri-fontaine.md>)

Topics: [PostgreSQL](<https://devfeed.tech/topics/postgresql.md>), [Extension](<https://devfeed.tech/topics/extension.md>)

Tags: [article](<https://devfeed.tech/tags/article.md>), [extensions](<https://devfeed.tech/tags/extensions.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [postgresql](<https://devfeed.tech/tags/postgresql.md>)

## AI overview

This tutorial explains how to calculate distances between geographic coordinates in PostgreSQL using the earthdistance contrib extension. It also demonstrates finding nearby and distant pubs, associating them with cities, and comparing query execution behavior.

## Source excerpt

In our recent article about The Most Popular Pub Names we did have a look at how to find the pubs nearby, but didn't compute the distance in between that pub and us. That's because how to compute a distance given a position on the earth expressed as longitude and latitude is not that easy. Today, we are going to solve that problem nonetheless, thanks to PostgreSQL Extensions.