Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1et9NM-00071e-Lw for pgsql-performance@arkaria.postgresql.org; Tue, 06 Mar 2018 09:59:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1et9NL-00006a-7h for pgsql-performance@arkaria.postgresql.org; Tue, 06 Mar 2018 09:59:15 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1et9NK-00006O-Sk for pgsql-performance@lists.postgresql.org; Tue, 06 Mar 2018 09:59:15 +0000 Received: from mx2.mailbox.org ([80.241.60.215]) by makus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1et9NH-0002we-GY for pgsql-performance@postgresql.org; Tue, 06 Mar 2018 09:59:13 +0000 Received: from smtp2.mailbox.org (smtp2.mailbox.org [80.241.60.241]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 7FBFE40F71; Tue, 6 Mar 2018 10:59:07 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter03.heinlein-hosting.de (spamfilter03.heinlein-hosting.de [80.241.56.117]) (amavisd-new, port 10030) with ESMTP id BgarzUhHltyp; Tue, 6 Mar 2018 10:59:06 +0100 (CET) Message-ID: <1520330344.2601.15.camel@cybertec.at> Subject: Re: GIST index (polygon, point) From: Laurenz Albe To: ghiureai , "pgsql-performance@postgresql.org" Date: Tue, 06 Mar 2018 10:59:04 +0100 In-Reply-To: References: Organization: Cybertec Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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