pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: ghiureai <isabella.ghiurea@nrc-cnrc.gc.ca>
To: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: GIST index (polygon, point)
Date: Tue, 06 Mar 2018 10:59:04 +0100
Message-ID: <1520330344.2601.15.camel@cybertec.at> (raw)
In-Reply-To: <f3102e7a-a1bd-026c-fbbc-9a50d9c7b68b@nrc-cnrc.gc.ca>
References: <f3102e7a-a1bd-026c-fbbc-9a50d9c7b68b@nrc-cnrc.gc.ca>

ghiureai wrote:
> I have a short description bellow from Dev team regarding the behaviour of gist index on the polygon column, looking to get some  feedback  from you:
>
> ".... I was expecting the <@(point,polygon) and @>(polygon,point) to be indexable but they are not. see bellow query output ,
> the column is a polygon and the index is a gist index on the polygon column; my understanding of the above query is that it says which operators would cause that index to be used
>
> This SQL shows which operators are indexable:SELECT
>  pg_get_indexdef(ss.indexrelid, (ss.iopc).n, TRUE) AS index_col,
>  amop.amopopr::regoperator AS indexable_operator
> FROM pg_opclass opc, pg_amop amop,
>  (SELECT indexrelid, information_schema._pg_expandarray(indclass) AS iopc
>   FROM pg_index
>   WHERE indexrelid = 'caom2.Plane_energy_ib'::regclass) ss
> WHERE amop.amopfamily = opc.opcfamily AND opc.oid = (ss.iopc).x
> ORDER BY (ss.iopc).n, indexable_operator;
>
> We run  the SQL  in PG 9.5.3 and PG 10.2 we  the same result: only polygon vs polygon is indexable (except the last entry which is distance operator).
> The work around for us was to change interval-contains-value from polygon-contains-point (@> or <@ operator) to
> polygn-intersects-really-small-polygon (&&) in order to use the index, but I was quite surprised that contains operators are not indexable!
> Note that this is using the built in polygon and not pgsphere (spoly)"

That sounds about right.

You could use a single-point polygon like '((1,1))'::polygon
and the <@ or && operator.

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com




view thread (2+ messages)

Message-ID: <1520330344.2601.15.camel@cybertec.at>
Permalink:  ../1520330344.2601.15.camel@cybertec.at/
Also on:    postgresql.org/message-id/1520330344.2601.15.camel@cybertec.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: laurenz.albe@cybertec.at, isabella.ghiurea@nrc-cnrc.gc.ca
  Subject: Re: GIST index (polygon, point)
  In-Reply-To: <1520330344.2601.15.camel@cybertec.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox