Re: Postgresql 11.3 doesn't use gist index on polygon column

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Вадим Самохин <samokhinvadim(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Postgresql 11.3 doesn't use gist index on polygon column
Date: 2022-11-17 15:52:56
Message-ID: 1833085.1668700376@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

=?UTF-8?B?0JLQsNC00LjQvCDQodCw0LzQvtGF0LjQvQ==?= <samokhinvadim(at)gmail(dot)com> writes:
> 6. But postgresql still doesn't want to use my index:
> postgres=# explain analyze select * from zonez where '(2,2)'::point <@ p;

It can't, because "polygon @> point" isn't one of the operators supported
by that opclass. You could use a polygon comparison:

=# \dAo gist poly_ops
List of operators of operator families
AM | Operator family | Operator | Strategy | Purpose
------+-----------------+----------------------+----------+----------
gist | poly_ops | <<(polygon,polygon) | 1 | search
gist | poly_ops | &<(polygon,polygon) | 2 | search
gist | poly_ops | &&(polygon,polygon) | 3 | search
gist | poly_ops | &>(polygon,polygon) | 4 | search
gist | poly_ops | >>(polygon,polygon) | 5 | search
gist | poly_ops | ~=(polygon,polygon) | 6 | search
gist | poly_ops | @>(polygon,polygon) | 7 | search
gist | poly_ops | <@(polygon,polygon) | 8 | search
gist | poly_ops | &<|(polygon,polygon) | 9 | search
gist | poly_ops | <<|(polygon,polygon) | 10 | search
gist | poly_ops | |>>(polygon,polygon) | 11 | search
gist | poly_ops | |&>(polygon,polygon) | 12 | search
gist | poly_ops | <->(polygon,point) | 15 | ordering
(13 rows)

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2022-11-17 17:35:55 Re: session_user different from current_user after normal login
Previous Message Fabrice Chapuis 2022-11-17 15:49:31 Re: pg_restore remap schema