Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Uw67v-0003zc-NX for pgsql-performance@arkaria.postgresql.org; Mon, 08 Jul 2013 07:44:51 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Uw67u-0003QX-GA for pgsql-performance@arkaria.postgresql.org; Mon, 08 Jul 2013 07:44:50 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Uw67r-0003Lj-3v for pgsql-performance@postgresql.org; Mon, 08 Jul 2013 07:44:47 +0000 Received: from archon2012.plus.com ([80.229.41.160] helo=mail.archonet.com) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Uw67o-0007XB-5y for pgsql-performance@postgresql.org; Mon, 08 Jul 2013 07:44:46 +0000 Received: from [192.168.1.13] (ariel.office.archonet.com [192.168.1.13]) by mail.archonet.com (Postfix) with ESMTP id 1C2D82C3877; Mon, 8 Jul 2013 08:44:41 +0100 (BST) Message-ID: <51DA6DE9.4030309@archonet.com> Date: Mon, 08 Jul 2013 08:44:41 +0100 From: Richard Huxton User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130116 Icedove/10.0.12 MIME-Version: 1.0 To: Radu-Stefan Zugravu CC: pgsql-performance@postgresql.org Subject: Re: How to properly index hstore tags column to faster search for keys References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: 0.8 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On 07/07/13 08:28, Radu-Stefan Zugravu wrote: > Each node has a geometry column called geom and a hstore column > called tags. I need to extract nodes along a line that have certain > keys in the tags column. To do that I use the following query: > SELECT id, tags > FROM nodes > WHERE ST_DWithin(nodes.geom, ST_MakeLine('{$geom1}', '{$geom2}'), 0.001) > AND tags ? '{$type}'; > CREATE INDEX nodes_tags_idx ON nodes USING GIN(tags); > > After creating the index I searched again for nodes using the same first > query but there is no change in performance. > > How can I properly use GIN and GIST to index tags column so I can faster > search for nodes that have a certain key in tags column? Your index definition looks OK. Try showing the output of EXPLAIN ANALYSE for your query - that way we'll see if the index is being used. You can always paste explain output to: http://explain.depesz.com/ if it's too long for the email. -- Richard Huxton Archonet Ltd -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance