Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id EA9F09FA354 for ; Mon, 5 Feb 2007 15:47:56 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 72103-03 for ; Mon, 5 Feb 2007 15:47:49 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id E28B09FA4CA for ; Mon, 5 Feb 2007 15:47:50 -0400 (AST) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id 0EBC730F3B; Mon, 5 Feb 2007 20:47:50 +0100 (MET) From: Mark Stosberg X-Newsgroups: pgsql.performance Subject: Re: optimizing a geo_distance() proximity query Date: Mon, 05 Feb 2007 14:47:25 -0500 Organization: Hub.Org Networking Services Lines: 28 Message-ID: References: <20070204051644.GA3754@wolff.to> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org User-Agent: Thunderbird 1.5.0.8 (X11/20061109) In-Reply-To: <20070204051644.GA3754@wolff.to> To: pgsql-performance@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=BAYES_50 X-Spam-Level: X-Archive-Number: 200702/49 X-Sequence-Number: 23103 Bruno Wolff III wrote: > On Sat, Feb 03, 2007 at 14:00:26 -0500, > Mark Stosberg wrote: >> I'm using geo_distance() from contrib/earthdistance would like to find a >> way to spend up the geo distance calculation if possible. This is for a >> proximity search: "Show me adoptable pets within 250 miles of this >> zipcode". > > If you are using the "cube" based part of the earth distance package, > then you can use gist indexes to speed those searches up. Thanks for the tip. Any idea what kind of improvement I can expect to see, compared to using geo_distance()? > There are functions for creating boxes that include all of the points some distance > from a fixed point. This is lossy, so you need to recheck if you don't > want some points a bit farther away returned. Also you would need to > pick a point to be where the zip code is located, rather than using area > based zip codes. This is also interesting. Is this approach practical if I want to index what's near each of about 40,000 US zipcodes, or the approach mostly useful if you there are just a small number of fixed points to address? I'm going to start installing the cube() and earth_distance() functions today and see where I can get with the approach. Mark