Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Uw7CT-00089b-4U for pgsql-performance@arkaria.postgresql.org; Mon, 08 Jul 2013 08:53:37 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Uw7CS-0004tB-EQ for pgsql-performance@arkaria.postgresql.org; Mon, 08 Jul 2013 08:53:36 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Uw7CR-0004t5-MM for pgsql-performance@postgresql.org; Mon, 08 Jul 2013 08:53:35 +0000 Received: from archon2012.plus.com ([80.229.41.160] helo=mail.archonet.com) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Uw7CN-0001nh-9Q for pgsql-performance@postgresql.org; Mon, 08 Jul 2013 08:53:34 +0000 Received: from [192.168.1.13] (ariel.office.archonet.com [192.168.1.13]) by mail.archonet.com (Postfix) with ESMTP id BBE742C4106; Mon, 8 Jul 2013 09:53:28 +0100 (BST) Message-ID: <51DA7E08.6090007@archonet.com> Date: Mon, 08 Jul 2013 09:53:28 +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: <51DA6DE9.4030309@archonet.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) 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 08/07/13 09:31, Radu-Stefan Zugravu wrote: > Hi, > Thank you for your answer. > My EXPLAIN ANALYZE output can be found here: > http://explain.depesz.com/s/Wbo. Thanks > Also, there is a discution on this subject on dba.stackexchange.com > : > http://dba.stackexchange.com/questions/45820/how-to-properly-index-hstore-tags-column-to-faster-search-for-keys Thanks - also useful to know. I can't see anything wrong with your query. Reading it from the bottom upwards: 1. Index used for "historic" search - builds a bitmap of blocks 2. Index used for geometry search - builds a bitmap of blocks 3. See where the bitmaps overlap (BitmapAnd) 4. Grab those disk blocks and find the rows (Bitmap Heap Scan) The whole thing takes under 20ms - what sort of time were you hoping for? The bulk of it (15ms) is taken up locating the "historic" rows. There are 36351 of those, but presumably most of them are far away on the map. Could you post the explain without the index? I'm curious as to how slow it is just testing the tags after doing the geometry search. -- 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