Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ah1Qo-0000X6-IJ for pgsql-bugs@arkaria.postgresql.org; Fri, 18 Mar 2016 20:55:38 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1ah1Qo-0002BS-4p for pgsql-bugs@arkaria.postgresql.org; Fri, 18 Mar 2016 20:55:38 +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_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1agrHF-0001RP-Kq for pgsql-bugs@postgresql.org; Fri, 18 Mar 2016 10:05:05 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1agrHC-0002c4-Uk for pgsql-bugs@postgresql.org; Fri, 18 Mar 2016 10:05:05 +0000 MIME-Version: 1.0 Subject: BUG #14032: trigram index is not used for '=' operator To: pgsql-bugs@postgresql.org From: ruslan.zakirov@gmail.com Date: Fri, 18 Mar 2016 10:04:27 +0000 Message-ID: <20160318100427.2903.57536@wrigleys.postgresql.org> X-Pg-Spam-Score: -0.3 (/) Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 14032 Logged by: Ruslan Email address: ruslan.zakirov@gmail.com PostgreSQL version: 9.4.6 Operating system: linux Description: Hi, Have table with the following index: "tags_local_name_trg" gin (lower(name::text) gin_trgm_ops) Was surprised that I have to use LIKE op to activate index: sports=> explain analyze select id from tags_local where lower(name) = 'xx'; QUERY PLAN ------------------------------------------------------------------------------------------------------------- Seq Scan on tags_local (cost=0.00..8647.17 rows=729 width=4) (actual time=188.669..188.669 rows=0 loops=1) Filter: (lower((name)::text) = 'xx'::text) Rows Removed by Filter: 145887 Planning time: 0.298 ms Execution time: 188.695 ms (5 rows) sports=> explain analyze select id from tags_local where lower(name) like 'xx'; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------ Bitmap Heap Scan on tags_local (cost=9.01..122.71 rows=729 width=4) (actual time=1.014..1.014 rows=0 loops=1) Recheck Cond: (lower((name)::text) ~~ 'xx'::text) -> Bitmap Index Scan on tags_local_name_trg (cost=0.00..8.82 rows=729 width=0) (actual time=1.013..1.013 rows=0 loops=1) Index Cond: (lower((name)::text) ~~ 'xx'::text) Planning time: 0.546 ms Execution time: 1.076 ms (6 rows) -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs