When looking at your query plan I wonder if one could reformulate the query to compute the ST_DWithin first (assuming you have an index on the node geometries!) before it filters the tags.
To investigate that you could formulate a CTE query [1] which computes the ST_DWithin first.
It seems to me that you trying hard to solve a problem by SQL that probably can't be solved. Take a look please on Apache HBase. You can access HBase from PostgreSQL as well by utilizing Java or Python for example.
Sincerely yours,
Yuri Levinsky, DBA
Celltick Technologies Ltd., 32 Maskit St., Herzliya 46733, Israel
Subject: Re: [PERFORM] How to properly index hstore tags column to faster search for keys
Any improvement is welcomed. The overall performance of the application is not very good. It takes about 200 seconds to compute a path for not so far star and end points. I want to improve this query as much as I can.
How exactly should I post the explain without the index? Do I have to drop all created indexes for the tags column? It takes some time to create them back.
On Mon, Jul 8, 2013 at 11:53 AM, Richard Huxton <dev@archonet.com> wrote:
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.