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 1gKM7U-0004VV-3B for pgsql-bugs@arkaria.postgresql.org; Wed, 07 Nov 2018 11:35:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gKM7S-0007e5-45 for pgsql-bugs@arkaria.postgresql.org; Wed, 07 Nov 2018 11:35:34 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gKM7R-0007dy-JE for pgsql-bugs@lists.postgresql.org; Wed, 07 Nov 2018 11:35:33 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gKM7J-0006VD-7y for pgsql-bugs@lists.postgresql.org; Wed, 07 Nov 2018 11:35:32 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 09B9B21C2497; Wed, 7 Nov 2018 14:35:23 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from [192.168.27.237] (gw.postgrespro.ru [93.174.131.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id D1ECA21C240D; Wed, 7 Nov 2018 14:35:22 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1541590522; bh=X7xR38WrzS0IknPGtHVqZ1nPu3J2ejsKxmq9Y/5owJE=; h=Subject:To:References:From:Date:In-Reply-To; b=BzHarKJJunPB0m6EOhI94AkB9ScBjBo63pfJA3pP2OWlaijjF/o9LmMVEUbNtqCyS 8B20tGXxjzC2i+yDLbfa7g6zfJ5+ug2N+dQ/Syv24v/jxHl60DF0gOW9k1J3/l0fkh owl2oQuMJDxcKouDgLSXejBT13QXgGE5u5lynlu0= Subject: Re: BUG #15491: index on function not being used for full text search when querying through a view To: allenwu1973@yahoo.co.jp, pgsql-bugs@lists.postgresql.org References: <15491-5bd96f27a237da50@postgresql.org> From: Arthur Zakirov Message-ID: Date: Wed, 7 Nov 2018 14:35:22 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <15491-5bd96f27a237da50@postgresql.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello, On 07.11.2018 11:30, PG Bug reporting form wrote: > I'm trying to implement full text search with PostgreSQL, > I found when using a function create index in conjunction with querying > through a view, will cause postgres not to use the index. > Below are example for each scenario. > > When only using expression index, the index is used > https://dbfiddle.uk/?rdbms=postgres_11&fiddle=16ed7a04389ebf71dc5a1fb2daa34058 > > When only using view, the index is also used > https://dbfiddle.uk/?rdbms=postgres_11&fiddle=e8d50181b8612421773c2da39e45c9fd > > view + expression, the index is NOT used > https://dbfiddle.uk/?rdbms=postgres_11&fiddle=19d7b923514f100f6e402b54624cc972 > > I've avoid using function in my app, but I think this should have worked. > Thank you I'm not strong in various function volatility categories. But it seems that STABLE function solves this. See: https://dbfiddle.uk/?rdbms=postgres_11&fiddle=eadfe2af10113ca53ff9698228728490 -- Arthur Zakirov Postgres Professional: http://www.postgrespro.com Russian Postgres Company