Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQKWM-00053d-1t for pgsql-sql@arkaria.postgresql.org; Thu, 11 Apr 2013 16:38:46 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UQKWL-0007zN-Hr for pgsql-sql@arkaria.postgresql.org; Thu, 11 Apr 2013 16:38:45 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQKWK-0007zF-M2 for pgsql-sql@postgresql.org; Thu, 11 Apr 2013 16:38:44 +0000 Received: from sam.nabble.com ([216.139.236.26]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UQKWH-0000OR-4z for pgsql-sql@postgresql.org; Thu, 11 Apr 2013 16:38:44 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1UQKWG-0006QZ-2K for pgsql-sql@postgresql.org; Thu, 11 Apr 2013 09:38:40 -0700 Date: Thu, 11 Apr 2013 09:38:39 -0700 (PDT) From: androclos To: pgsql-sql@postgresql.org Message-ID: <1365698318594-5751814.post@n5.nabble.com> Subject: Slow update with ST_Contians() MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: 1.2 (+) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org UPDATE tbl SET city=s.city_name FROM shp AS s WHERE ST_CONTAINS(s.city_geom,geom); With the code above i can add exact city to a GPS point. It runs about 45-50 min on 50 million rows. There are about 4000 cities in the "city" table that have to be checked. I have another shape file with 19 counties in a given country(only 1 country). It takes it about 1,5 hour to add counties to points. i have a third shape file with 52 EU countries. It runs almost 25 hours with the same sql query. Every table has index by geom, like: CREATE INDEX idx_txt_geom ON txt USING GIST(geom); Q: Why is it so slow when it has to check only a few polygons ? -- View this message in context: http://postgresql.1045698.n5.nabble.com/Slow-update-with-ST-Contians-tp5751814.html Sent from the PostgreSQL - sql mailing list archive at Nabble.com. -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql