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 1is8t7-0007el-OH for pgsql-general@arkaria.postgresql.org; Thu, 16 Jan 2020 17:24:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1is8t6-00075i-Ii for pgsql-general@arkaria.postgresql.org; Thu, 16 Jan 2020 17:24:56 +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 1is8t6-00072m-5z for pgsql-general@lists.postgresql.org; Thu, 16 Jan 2020 17:24:56 +0000 Received: from mail.verite.pro ([185.16.44.216]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1is8t0-0002QG-Rm for pgsql-general@lists.postgresql.org; Thu, 16 Jan 2020 17:24:54 +0000 Received: from genius-map.net (verite.pro [195.154.189.246]) by mail.verite.pro (Postfix) with ESMTP id AE9958C00DF; Thu, 16 Jan 2020 18:17:20 +0100 (CET) Received: by genius-map.net (Postfix, from userid 1001) id 894F738A0E9A; Thu, 16 Jan 2020 18:24:49 +0100 (CET) Content-Type: text/plain; charset="iso-8859-15" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: Inexplicable duplicate rows with unique constraint From: "Daniel Verite" To: "Richard van der Hoff" Cc: pgsql-general@lists.postgresql.org In-Reply-To: <288488b7-d3b6-905b-3706-43f7a3c7bc52@matrix.org> Date: Thu, 16 Jan 2020 18:24:48 +0100 Message-Id: X-Mailer: Manitou v1.7.3 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Richard van der Hoff wrote: > synapse=3D> select count(*), room_id, type, state_key from=20 > current_state_events group by 2,3,4 order by count(*) DESC LIMIT 2; > count | room_id | type | state_key > -------+-----------------------------------+---------------+-------------= ------------------------ > 3 | !ueLfVrSWYGMnFnoCbT:darkfasel.net | m.room.member |=20 > @irc_ebi_:darkfasel.net > 3 | !HwocBmCtBcHQhILtYQ:matrix.org | m.room.member |=20 > @freenode_AlmarShenwan_:matrix.org Looking at these columns which are of type text but do not contain words of any particular language, there's probably no point in using a linguistic-aware collation for them. If you maintain the database schema, what you could do to avoid the dependency on the OS collation and stay clear of the particular upgrade difficulty of collations is to use COLLATE "C" for this kind of field, as opposed to the default collation of the database. As a bonus, operations with the "C" collations tend to be faster, sometimes even much faster. Best regards, --=20 Daniel V=E9rit=E9 PostgreSQL-powered mailer: http://www.manitou-mail.org Twitter: @DanielVerite