Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ovhCK-0008VT-Vu for pgsql-general@arkaria.postgresql.org; Thu, 17 Nov 2022 15:53:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ovhCH-0003pb-2m for pgsql-general@arkaria.postgresql.org; Thu, 17 Nov 2022 15:53:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ovhCG-0003ot-OA for pgsql-general@lists.postgresql.org; Thu, 17 Nov 2022 15:53:00 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ovhCE-0002TL-LR for pgsql-general@lists.postgresql.org; Thu, 17 Nov 2022 15:53:00 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 2AHFqutd1833086; Thu, 17 Nov 2022 10:52:56 -0500 From: Tom Lane To: =?UTF-8?B?0JLQsNC00LjQvCDQodCw0LzQvtGF0LjQvQ==?= cc: pgsql-general@lists.postgresql.org Subject: Re: Postgresql 11.3 doesn't use gist index on polygon column In-reply-to: References: Comments: In-reply-to =?UTF-8?B?0JLQsNC00LjQvCDQodCw0LzQvtGF0LjQvQ==?= message dated "Thu, 17 Nov 2022 18:45:02 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1833084.1668700376.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 17 Nov 2022 10:52:56 -0500 Message-ID: <1833085.1668700376@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk =3D?UTF-8?B?0JLQsNC00LjQvCDQodCw0LzQvtGF0LjQvQ=3D=3D?=3D writes: > 6. But postgresql still doesn't want to use my index: > postgres=3D# 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: =3D# \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 | ~=3D(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