Re: [GENERAL] Postgres not using GiST index in a lateral join

2015-03-05 Thread Igor Stassiy
I got the query plan using: EXECUTE EXPLAIN (format json) ... INTO query_plan; RAISE NOTICE query_plan; since by default EXPLAIN returns a set of rows and I'd have to create a table for storing that. As I mentioned in the original email, the queries and output is nicely formatted at:

Re: [GENERAL] Postgres not using GiST index in a lateral join

2015-03-04 Thread Paul Ramsey
Stop writing so many subqueries, think in joins; the poor planner! SELECT DISTINCT ON (a.id) a.id AS a_id, b.id AS b_id FROM a JOIN b ON ST_Contains(b.shape, a.shape) WHERE b.kind != 1 Also, the DISTINCT ON syntax (PgSQL custom) lets you winnow a result set down to just one of the inputs. P.

Re: [GENERAL] Postgres not using GiST index in a lateral join

2015-03-04 Thread Igor Stassiy
I would like to stop executing the query for a row of table a when a single row of b is found. This query would not stop processing but will filter all the rows that are found at the end of execution. Is there a way to express this without a subquery? On Wed, Mar 4, 2015 at 11:53 PM Paul Ramsey

Re: [GENERAL] Postgres not using GiST index in a lateral join

2015-03-04 Thread Alban Hertroys
On 04 Mar 2015, at 22:18, Igor Stassiy istas...@gmail.com wrote: I would like to stop executing the query for a row of table a when a single row of b is found. This query would not stop processing but will filter all the rows that are found at the end of execution. Is there a way to

[GENERAL] Postgres not using GiST index in a lateral join

2015-03-04 Thread Igor Stassiy
Hello, I have a query plan optimization question. It is formatted nicely on http://stackoverflow.com/questions/28856452/postgres-not-using-gist-index-in-lateral-join But here is a copy for the archive: Here is the setup: CREATE EXTENSION postgis; DROP TABLE IF EXISTS A; DROP TABLE IF EXISTS