Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y1ej6-0003Wl-J2 for pgsql-performance@arkaria.postgresql.org; Thu, 18 Dec 2014 17:19:00 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Y1ej5-0006Ro-UX for pgsql-performance@arkaria.postgresql.org; Thu, 18 Dec 2014 17:18:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Y1ej3-0006Oh-Rp for pgsql-performance@postgresql.org; Thu, 18 Dec 2014 17:18:57 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Y1ej0-0006JJ-Ib for pgsql-performance@postgresql.org; Thu, 18 Dec 2014 17:18:56 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id sBIHIqtx018098; Thu, 18 Dec 2014 12:18:52 -0500 From: Tom Lane To: Robert DiFalco cc: "pgsql-performance@postgresql.org" Subject: Re: Question about trigram GIST index In-reply-to: References: Comments: In-reply-to Robert DiFalco message dated "Thu, 18 Dec 2014 09:12:16 -0800" Date: Thu, 18 Dec 2014 12:18:52 -0500 Message-ID: <18097.1418923132@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Robert DiFalco writes: > So, for my use case I simply need to search for a case insensitive > substring. It need not be super exact. It seems like there are two ways I > can do this: > CREATE INDEX idx_users_name ON users USING GIST(lower(name) gist_trgm_ops); > SELECT * FROM users WHERE lower(name) LIKE '%john%'; > Or I can do it like this: > CREATE INDEX idx_users_name ON users USING GIST(name gist_trgm_ops); > SELECT * FROM users WHERE name % 'john'; Hm, I don't see anything in the pg_trgm docs suggesting that % is case-insensitive. But in any case, I'd go with the former as being more understandable to someone who knows standard SQL. regards, tom lane -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance