Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ecBvI-0002Mn-4F for pgsql-bugs@arkaria.postgresql.org; Thu, 18 Jan 2018 15:16:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ecBvH-0005ZE-MP for pgsql-bugs@arkaria.postgresql.org; Thu, 18 Jan 2018 15:16:11 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ecBvH-0005Z5-Db for pgsql-bugs@lists.postgresql.org; Thu, 18 Jan 2018 15:16:11 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ecBvA-00065q-Ch; Thu, 18 Jan 2018 15:16:09 +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 w0IFFrI1018068; Thu, 18 Jan 2018 10:15:54 -0500 From: Tom Lane To: digoal@126.com, pgsql-bugs@lists.postgresql.org, =?utf-8?q?PG_Bug_reporting_form?= Subject: Re: BUG #15014: pg_trgm regexp with wchar not good? In-reply-to: <20180118130346.3630.56019@wrigleys.postgresql.org> References: <20180118130346.3630.56019@wrigleys.postgresql.org> Comments: In-reply-to =?utf-8?q?PG_Bug_reporting_form?= message dated "Thu, 18 Jan 2018 13:03:46 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <18066.1516288553.1@sss.pgh.pa.us> Date: Thu, 18 Jan 2018 10:15:53 -0500 Message-ID: <18067.1516288553@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk =?utf-8?q?PG_Bug_reporting_form?= writes: > when i use pg_trgm's gin index, with wchar search, it's not good for regexp, > but good for like express. pg_trgm is going to ignore characters that it doesn't think are letters or digits. Don't know if the characters you are working with are considered letters in en_US locale, but if they aren't, that would likely result in no usable trigrams in this string. Another issue is that "trigrams" are three *bytes* not three characters, so the useful information per trigram is a lot lower when working with many-byte characters; that could also lead to an index search being much less selective than you'd hope. You might learn something by looking at the result of show_trgm() for these strings, but I'm thinking there's no bug here, just design limitations of the trigram approach. regards, tom lane