Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gzI0F-0007Xm-VY for pgsql-general@arkaria.postgresql.org; Thu, 28 Feb 2019 09:29:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gzI0C-0008Ss-UJ for pgsql-general@arkaria.postgresql.org; Thu, 28 Feb 2019 09:29:16 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gzI0C-0008Qz-Jx for pgsql-general@lists.postgresql.org; Thu, 28 Feb 2019 09:29:16 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gzI06-0004Fk-2y for pgsql-general@postgresql.org; Thu, 28 Feb 2019 09:29:15 +0000 Received: from [192.168.127.1] (port=27403 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1gzI03-0009yc-DN; Thu, 28 Feb 2019 09:29:07 +0000 Received: from [127.0.0.1] (port=37582 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1gzI02-000Ibd-K2; Thu, 28 Feb 2019 09:29:06 +0000 From: Andrew Gierth To: Thomas Kellerer Cc: pgsql-general@postgresql.org Subject: Re: Overloaded && operator from intarray module prevents index usage. In-Reply-To: (Thomas Kellerer's message of "Thu, 28 Feb 2019 08:47:11 +0100") Message-ID: <87ef7se0q3.fsf@news-spur.riddles.org.uk> References: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix) Date: Thu, 28 Feb 2019 09:29:03 +0000 MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk >>>>> "Thomas" == Thomas Kellerer writes: [intarray woes] Thomas> Is this expected behaviour? Is this caused by the Postgres core Thomas> (e.g. the optimizer to taking the opclass into account) or is Thomas> it a "problem" in the way the intarray module defines its Thomas> operators? It's basically a conflict between intarray (which is historically older) and the built-in array indexing support. The reason it happens is that the operator resolution logic matches an (integer[] && integer[]) operator in preference to (anyarray && anyarray) regardless of their relative position on the search_path. This resolution happens before anything is known about any indexes that might be applicable. Then later, at planning time, an index is chosen based on the operator, not the reverse. My own recommendation for most cases is to never install intarray on the search path, and invoke its functions via explicit qualification or wrap them in your own functions. -- Andrew (irc:RhodiumToad)