Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 921C4632400 for ; Wed, 4 Aug 2010 13:41:55 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 92434-09 for ; Wed, 4 Aug 2010 16:41:48 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 85A8B6321F9 for ; Wed, 4 Aug 2010 13:41:48 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o74Gfl6a021080; Wed, 4 Aug 2010 12:41:47 -0400 (EDT) To: "Kevin Grittner" cc: pgsql-performance@postgresql.org Subject: Re: LIKE without wildcard different from = In-reply-to: <4C59503402000025000341C0@gw.wicourts.gov> References: <4C59503402000025000341C0@gw.wicourts.gov> Comments: In-reply-to "Kevin Grittner" message dated "Wed, 04 Aug 2010 11:34:12 -0500" Date: Wed, 04 Aug 2010 12:41:47 -0400 Message-ID: <21079.1280940107@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201008/44 X-Sequence-Number: 39887 "Kevin Grittner" writes: > We have been using the C locale for everything at our site, but > there is occasionally talk of supporting characters outside the > ASCII7 set. In playing around with indexing, to see what the impact > of that would be, I stumbled across something which was mildly > surprising. > In the C locale, if you want to search for an exact value which > doesn't contain wildcard characters, it doesn't matter whether you > use the 'LIKE' operator or the '=' operator. With LATIN1 encoding, > it made three orders of magnitude difference, both in the estimated > cost and the actual run time. What PG version are you testing? 8.4 and up should know that an exact-match pattern can be optimized regardless of the lc_collate setting. regards, tom lane