Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r44gv-007FKj-2v for pgsql-hackers@arkaria.postgresql.org; Fri, 17 Nov 2023 19:39:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1r44gt-00FTd7-Kg for pgsql-hackers@arkaria.postgresql.org; Fri, 17 Nov 2023 19:39:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r44gt-00FTcy-Ap for pgsql-hackers@lists.postgresql.org; Fri, 17 Nov 2023 19:39:47 +0000 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1r44gq-006x0b-T1 for pgsql-hackers@postgresql.org; Fri, 17 Nov 2023 19:39:46 +0000 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1cc5b705769so21118155ad.0 for ; Fri, 17 Nov 2023 11:39:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20230601.gappssmtp.com; s=20230601; t=1700249982; x=1700854782; darn=postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=ZZVCsUKMu4D+whmtM+UH15QzOokdQeyroXwzjE7uZbk=; b=gsZJkQ69VHa8TRZXtB8MWbrlKE7q5DyWC/Fr7g1hTHsVABBb0dRE5AC1wKxRWy2YkT R+GOGeb7cLeIguZwlncAs0Vmq5x3CysX5t9bSp0r6exhNd9TpP4VO8tf6up4jMj/57vR ATSxjqI1msL8zv/0OQzUIVO71GFYQ2Y8IRt178QTyqBI9oreTifZucGjm/qMQGIYPp7V 1c3ZDP0oSzfbV3skiArDIokhiMAKK48xbjMHXtwl2zph+J+WBEonLw/nmSIB9LbTJO83 20yGWgUMtQFSiFxg2oIysgGYiXxO6YTFLfOCSFjImmMbdQvZi1osDj+JCcoaLAiQvxPs 6KEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700249982; x=1700854782; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ZZVCsUKMu4D+whmtM+UH15QzOokdQeyroXwzjE7uZbk=; b=FT/ja3Pm7dmM8jmPHhOvQYG5h77a/uMV9Q0nYrIXmX4DgyIGT34fCoO4Eu7GAYrURb ERgE3ZYoLIwVIIH5tWGUzFcvZV2vlioUH5khd/YKKewvDV+Y5R5ycM74D23fBkG0+cRe IsgB7iQBkuNUALQ+CBgvvUhCN5pW9YTE9A2PYc3i9KMEwVxGVVEGtezD3NnGbgF8pTiA 094bnI1gbkheYz+fZxz+ihCuGlG0z0sVQ/j1jzQBiUZZuYoOF5s36e1ks2yNd+V0QF/u hWWXnGXti5NZklXQVpDATgDNIBixHKI8kWzQCQcbbYHNEjsod9qu+43QUIdNIL72Ng9p h/WA== X-Gm-Message-State: AOJu0Yx2+92k7XnOT1nvMg7AzG7jt8SVzYaFi3UhHtYuw1T4oStfjJDh y3Vq7l12bIcFBFH+uM2SjPV6hQ== X-Google-Smtp-Source: AGHT+IG/GlM+8miVciFkdrG5FWtspVeznzXEh8+oIc2qVQtj/ztp0K0uifo4an7c231dg+e8+0V0hw== X-Received: by 2002:a17:903:32d0:b0:1ce:16e7:f4f8 with SMTP id i16-20020a17090332d000b001ce16e7f4f8mr700594plr.11.1700249982409; Fri, 17 Nov 2023 11:39:42 -0800 (PST) Received: from [172.18.10.36] ([12.126.244.130]) by smtp.gmail.com with ESMTPSA id w16-20020a170902d71000b001cc56354cc8sm1739216ply.62.2023.11.17.11.39.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 11:39:41 -0800 (PST) Message-ID: <13fb2032cbfda29bb4c6c55ccc41a3d01a8de717.camel@j-davis.com> Subject: Re: Why do indexes and sorts use the database collation? From: Jeff Davis To: Andres Freund , Tomas Vondra Cc: pgsql-hackers@postgresql.org Date: Fri, 17 Nov 2023 11:39:40 -0800 In-Reply-To: <20231113221212.lgjhziuavnmapeu3@awork3.anarazel.de> References: <20231111011943.ktfppxrcqtjo66bg@alap3.anarazel.de> <78ae1ecb0ad181e1a9352ec0d497d88304c974bb.camel@j-davis.com> <20231113180247.vud4c5uy77ojf6sx@awork3.anarazel.de> <89e23afc-97b7-bf4c-44fb-3fa0a90dad58@enterprisedb.com> <20231113221212.lgjhziuavnmapeu3@awork3.anarazel.de> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4-0ubuntu2 MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2023-11-13 at 14:12 -0800, Andres Freund wrote: > Why on earth are we solving this by having multiple pg_collation > entries for > exactly the same collation, instead of normalizing the collation-name > during > lookup by adding the relevant encoding name if not explicitly > specified?=C2=A0 It > makes a lot of sense to not force the user to specify the encoding > when it > can't differ. I'm not aware of it being a common practical problem, so perhaps lack of motivation. But you're right that it doesn't look very efficient. We can even go deeper into ICU if we wanted to: lots of locales are actually aliases to a much smaller number of actual collators. And a lot are just aliases to the root locale. It's not trivial to reliably tell if two collators are identical, but in principle it should be possible: each collation is just a set of tailorings on top of the root locale, so I suppose if those are equal it's the same collator, right? > It's imo similarly absurd that an index with "default" collation > cannot be > used when specifying the equivalent collation explicitly in the query > and vice > versa. The catalog representation is not ideal to treat the database collation consistently with other collations. It would be nice to fix that. > > > >=20 > Jeff was saying that textual primary keys typically don't need > sorting and > because of that we could default to "C", for performance. Part of my > response > was that I think the user's intent could be expressed by specifying > the column > collation as "C" - to which Jeff replied that that would change the > semantics. Which, to me, seems to completely run counter to his > argument that > we could just use "C" for such indexes. I am saying we shouldn't prematurely optimize for the case of ORDER BY on a text PK case by making a an index with a non-"C" collation, given the costs and risks of non-"C" indexes. Particularly because, even if there is an ORDER BY, there are several common reasons such an index would not help anyway. > > > >=20 Regards, Jeff Davis