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 1jTabD-00011u-Ld for pgsql-general@arkaria.postgresql.org; Wed, 29 Apr 2020 00:29:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jTabC-0004Bg-Ia for pgsql-general@arkaria.postgresql.org; Wed, 29 Apr 2020 00:29:14 +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 1jTabB-0004BY-Bm for pgsql-general@lists.postgresql.org; Wed, 29 Apr 2020 00:29:14 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jTab3-00086S-RD for pgsql-general@postgresql.org; Wed, 29 Apr 2020 00:29:13 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 3FC495C055D; Tue, 28 Apr 2020 20:29:03 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 28 Apr 2020 20:29:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm2; bh=Y IFiRC6IcXIAcBZ8K/gpOa0+sSKDEYFDew+rsea32fo=; b=jY64ySi8WZ8kJILcB JkEyndjaplaJi5gwAoLeUpIrIh+9miFiYSv/5dFWHbv3yoHdDY0gMvNYujbqMEhY G/0lxP3WYilVpGE3GhDe//3l9LhjFarUS2/0AebrruboOJCEpnTHEc0+dfsJQkWe xsIVMTzd9jkbk7M7k9nuNK6depsCv1ZnoaNbeq6xCMTC62GT3V/lnrx8e7UU94g9 7oF7bupg6PwcprflxLbjmtDw5inuYr9e5b7bCe7jrLcTHEcF035VfULWIz7knRyj hP9SrPYO30nldZP8cT7OGGV3AyrlkOQbG6j/x2c9aLArXO19u8fpAJLwVJh1id55 z3kIA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=YIFiRC6IcXIAcBZ8K/gpOa0+sSKDEYFDew+rsea32 fo=; b=ufoSBWFdARir4hisagNMkbr8/d+/QF5X1Ve0C0P8xo/+g7Kblu+kyh8Pn jnBcncusDT4776oIKEtMKkIrLN/hzw+L+tjf2PMvdj4yWnZJqbwdd+FPFyRy1pb1 pJFGqYm/c3pBpv5vZ2iI00C7Oe+yQWiSP6LAUdxtyMPBMLoaEb8Dy81tXjd+b/Tx DMr+HxWu9K29w8aQaRy7MBDnTEKfpENZyaLSrP3ib6bQOSCEnPNltJkOAdFuN0Mw iiR9NaCru1MSVs/DHfmZhHVway/uGuBh+4QHJmcw+bVQrKYuiI/9KErAxCvnMLOY jJL6S9QB+wFK9sPgFnnJOxOBh5Umw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedriedvgdeffecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefuvfhfhffkffgfgggjtgfgsehtkeertddtfeejnecuhfhrohhmpeetughrihgr nhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh eqnecukfhppeeljedruddufedrvddtjedrudefkeenucevlhhushhtvghrufhiiigvpedt necurfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrg hvvghrrdgtohhm X-ME-Proxy: Received: from [192.168.1.10] (97-113-207-138.tukw.qwest.net [97.113.207.138]) by mail.messagingengine.com (Postfix) with ESMTPA id 5C982328005A; Tue, 28 Apr 2020 20:29:02 -0400 (EDT) Subject: Re: GIN Expression Indexes To: Taylor Sarrafian , pgsql-general@postgresql.org References: From: Adrian Klaver Message-ID: Date: Tue, 28 Apr 2020 17:29:01 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 4/28/20 1:58 PM, Taylor Sarrafian wrote: > Hi friends! > > We tried to index an array function like this: > >   CREATE INDEX my_arr_index ON my_table USING GIN ( my_arr_func( my_col ) ) > > But the planner can’t seem to figure out how to use the index with any > query! It doesn’t work with any array operators. > >   SELECT * FROM my_table WHERE ARRAY[ 123 ]::INT[] && my_arr_func( my_col ) > > Even weirder, an empty array correctly uses the index: > >   SELECT * FROM my_table WHERE ARRAY[]::INT[] && my_arr_func( my_col ) > > Is there any way to coerce Postgres into using this index? Thanks! Well without: 1) Table schema. 2) EXPLAIN ANALYZE for the query(s) there is really not information to formulate an answer. > > ts -- Adrian Klaver adrian.klaver@aklaver.com