Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id C411C9FBD17 for ; Thu, 15 Feb 2007 12:13:46 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-new, port 10024) with ESMTP id 68882-07 for ; Thu, 15 Feb 2007 12:13:36 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.229]) by postgresql.org (Postfix) with ESMTP id 0D10D9FB94A for ; Thu, 15 Feb 2007 12:13:35 -0400 (AST) Received: by wr-out-0506.google.com with SMTP id i7so936549wra for ; Thu, 15 Feb 2007 08:13:35 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=JcaWaNNBpD7Yxdg9Pt3N9x7+lB9a3aQuWWqFHPbE8+X1oCpSQMwYBgi2miczpqKUtlVHmELcbH7NBoJVnnO3JTgSac6/KZIIAZoEqdDsA09VV7QcE/H//wYXLRGKU9in+i8UOLPrbVv+uqP7Ww+zMPoRrb9Aex9wCkH3ts7zZtY= Received: by 10.90.113.18 with SMTP id l18mr2634943agc.1171556014794; Thu, 15 Feb 2007 08:13:34 -0800 (PST) Received: by 10.90.113.7 with HTTP; Thu, 15 Feb 2007 08:13:34 -0800 (PST) Message-ID: <1d4e0c10702150813p19df3108sf2a7c82c38360a0a@mail.gmail.com> Date: Thu, 15 Feb 2007 17:13:34 +0100 From: "Guillaume Smet" To: "Paul Ramsey" Subject: Re: Proximity query with GIST and row estimation Cc: "Pg Performance list" In-Reply-To: <0BD9E842-2DA7-4F90-A732-AFD60C1F50C7@refractions.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1d4e0c10702130909g3be0a10fpf2594574c84866c9@mail.gmail.com> <0BD9E842-2DA7-4F90-A732-AFD60C1F50C7@refractions.net> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/172 X-Sequence-Number: 23226 On 2/14/07, Paul Ramsey wrote: > You'll find that PostGIS does a pretty good job of selectivity > estimation. So I finally have a working PostGIS and I fixed the query to use PostGIS. The use of PostGIS is slower than the previous cube/earthdistance approach (on a similar query and plan). But you're right, it does a pretty good job to calculate the selectivity and the estimations are really good. It helps to select a good plan (or a bad one if the previous false numbers led to a better plan which is my case for certain queries). I suppose it's normal to be slower as it's more precise. I don't know which approach is better in my case as I don't need the precision of PostGIS. For the record, here is what I did: select AddGeometryColumn('lieu','earthpoint',32631,'POINT',2); update lieu set earthpoint=Transform(SetSRID(MakePoint(wgslon, wgslat), 4327), 32631); create index idx_lieu_earthpoint on lieu using gist(earthpoint gist_geometry_ops); analyze lieu; select numlieu, nomlieu, wgslon, wgslat, astext(earthpoint) from lieu where earthpoint && Expand(Transform(SetSRID(MakePoint(12.49244400, 41.89103400), 4326), 32631), 3000); (3000 is the distance in meters) -- Guillaume