From: Mark Stosberg <mark@summersault.com>
To: pgsql-performance@postgresql.org
Subject: tip: faster sorting for proximity queries by using cube_distance()
Date: Wed, 07 Feb 2007 16:30:16 -0500
Message-ID: <eqdge4$291m$1@news.hub.org> (raw)
In-Reply-To: <eq8d0b$26cd$1@news.hub.org>
References: <eq2m5o$8cr$1@sea.gmane.org>
<20070204051644.GA3754@wolff.to>
<eq81l5$2na3$1@news.hub.org>
<b42b73150702051215s6fe341e2re43872ab84abb185@mail.gmail.com>
<eq8d0b$26cd$1@news.hub.org>
Hello,
I wanted to share something else I learned in my proximity search work.
One my requirements is to order by the distance that matches are found
from the center point.
When did this using earth_distance(), the benefit of the earth_box()
technique over the old geo_distance became minimal as I approached a
250mi radius.
Switching to sorting by cube_distance() offered a huge benefit, allowing
the earth_distance() query to run in about 100ms vs 300ms for the
geo_distance() equivalent.
I checked the results that cube_distance() produced versus
earth_distance(). cube_distance() is always (not surprisingly) a little
smaller, but the difference seems only grows to about a mile for a 250
mile radius. That's an acceptable margin of error for this application,
and may be for others as well.
Mark
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: mark@summersault.com
Subject: Re: tip: faster sorting for proximity queries by using cube_distance()
In-Reply-To: <eqdge4$291m$1@news.hub.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox