Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hMFmB-00005W-Ct for pgsql-general@arkaria.postgresql.org; Thu, 02 May 2019 17:45:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hMFm8-0003RW-Co for pgsql-general@arkaria.postgresql.org; Thu, 02 May 2019 17:45:40 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hMFm7-0003R0-QD for pgsql-general@lists.postgresql.org; Thu, 02 May 2019 17:45:40 +0000 Received: from smtp47.i.mail.ru ([94.100.177.107]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hMFm0-0001uF-7z for pgsql-general@postgresql.org; Thu, 02 May 2019 17:45:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.ru; s=mail2; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject; bh=nr/mdV8U8gZd84Yi/s7oYVwxz6LYcpRjH6UXX3snKGE=; b=lJ30Z7kBkEyVmMpRuIBUHinkIBAmWobA3/QCgt7uif3PHVcammwgzTFQ0w4ee6q58h/+YySbEnzBt+qzqSR7z1KCvdPCV9J8LFH6yO/RcbRp5vVeFIppQBBsRsF27b2mZku9HGBZlt+gxG2BC7po2eBApdspJVsLkvpBcqYcWkM=; Received: by smtp47.i.mail.ru with esmtpa (envelope-from ) id 1hMFlv-00060H-SR; Thu, 02 May 2019 20:45:28 +0300 Subject: Re: Upgrading locale issues To: Daniel Verite Cc: Peter Geoghegan , pgsql-general General References: From: rihad Message-ID: <352ac37a-39e6-5afe-d822-b4e031b9b314@mail.ru> Date: Thu, 2 May 2019 21:45:25 +0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=iso-8859-15; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Authentication-Results: smtp47.i.mail.ru; auth=pass smtp.auth=rihad@mail.ru smtp.mailfrom=rihad@mail.ru X-77F55803: BBE463BEF7A60BD05A78504BD2AC29419190768C267DA4DCEFCAA07867FB115701CAD21687A61E6E253496B426C2D549 X-7FA49CB5: 0D63561A33F958A59FFBAC18B2AF99EE3C53ABD300A033CCB8DE45FF502E727A8941B15DA834481FA18204E546F3947C1E44367C8E80A7B4F6B57BC7E64490618DEB871D839B7333395957E7521B51C2545D4CF71C94A83E9FA2833FD35BB23D27C277FBC8AE2E8B791E6C230873D55CA471835C12D1D977C4224003CC8364767815B9869FA544D8D32BA5DBAC0009BE9E8FC8737B5C2249CF022B9B1C4215823AA81AA40904B5D9CF19DD082D7633A093541453170D46FCD81D268191BDAD3D78DA827A17800CE7542AF255F21831B5CD04E86FAF290E2DBBC930A3941E20C675ECD9A6C639B01B78DA827A17800CE7E051670E9E32115CE917ADE49A7D3D2975ECD9A6C639B01B4E70A05D1297E1BBC6867C52282FAC8519DC0BE04022C72727F269C8F02392CD5571747095F342E88FB05168BE4CE3AF X-Mailru-Sender: B19AB4DAF1EA2FB5C00A13E8F74C9B2A1A2E4DFC79E40039A4345E6FBBF294DBF1E90838FFE501F5ABBFE0CF075BC50BFB559BB5D741EB96004FA9CEFBA991DA3A5DB60FBEB33A8A0DA7A0AF5A3A8387 X-Mras: OK List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 05/02/2019 05:36 PM, Daniel Verite wrote: > rihad wrote: > >> Thanks for the reply. Do you know what would a "decent" ICU collation be >> to bind to a field's schema definition so it would mimic a UTF-8 >> encoding for a multilingual column? Maybe und-x-icu? We aren't as much >> concerned about their sortability in most cases, we just want indexes to >> better handle future PG/ICU upgrades. But what does und(efined) even >> mean with respect to collations? > "undefined" in this context means unspecified language and > unspecified country or region. It implies that no language-specific > nor regional rule will be applied to compare strings. > > Using C.UTF-8 as the collation for text fields to index may be the > best trade-off in your case. It should be immune to libc and ICU > upgrades. > > With C.UTF-8, a string like 'BC' will sort before 'ab', and punctuation > and accents will also sort differently than with a linguistic-aware > collation. Thanks, I'm a bit confused here. AFAIK indexes are used for at least two things: for speed and for skipping the ORDER BY step (since btree indexes are already sorted). Will such an "upgrade-immune" C.UTF-8 index still work correctly for table lookups? And can the existing  en_US.UTF-8 fields' definition be altered in place, without a dump+restore? en_US.UTF-8 is the default encoding+locale+collation, it isn't set explicitly for any of our string columns. I assume there's some "catch-all" ordering taking place even for the C locale, so there won't be any bizarre things like b coming before a, or generally for any language, the second letter of its alphabet coming before the first? > If your applications care about that, it can be fixed by simply > adding COLLATE "default" to the ORDER BY clause of the queries that > are meant to present data to users. > COLLATE "default" means the collation of the database, which > presumably would be something like "language_REGION.UTF-8" in your > case. If you never specified it explicitly, it came from initdb which > itself got it from the environment of the server. > > > Best regards,