Обсуждение: database collation "C" and "C.LATIN1"

Поиск
Список
Период
Сортировка

database collation "C" and "C.LATIN1"

От
"James Pang (chaolpan)"
Дата:

Hi,

  We create one database with collate= “C.LATIN1”, any difference between “C” and “C.LATIN1” ?    database encoding is “LATIN1”.

 

oid  |        collname        | collnamespace | collowner | collprovider | collisdeterministic | collencoding |   collcollate    |    collctype     | collv

ersion

-------+------------------------+---------------+-----------+--------------+---------------------+--------------+------------------+------------------+------

-------

  950 | C                      |            11 |        10 | c            | t                   |           -1 | C                | C                |

12328 | C.latin1               |            11 |        10 | c            | t                   |            8 | C.latin1         | C.latin1    

 

Thanks,

 

James

Re: database collation "C" and "C.LATIN1"

От
Laurenz Albe
Дата:
On Thu, 2023-03-09 at 08:22 +0000, James Pang (chaolpan) wrote:
> We create one database with collate= “C.LATIN1”, any difference between “C” and “C.LATIN1” ?
> database encoding is “LATIN1”.
>  
>   oid  |        collname        | collencoding |   collcollate    |    collctype     | collversion
> -------+------------------------+--------------+------------------+------------------+-------------
>    950 | C                      |           -1 | C                | C                |
>  12328 | C.latin1               |            8 | C.latin1         | C.latin1         |

The difference is a technicality: "C" is encoding agnostic (-1) and can be used with
any encoding, while "C.latin1" can only be used with encoding LATIN1 (8).
The behavior is the same.

Yours,
Laurenz Albe

RE: database collation "C" and "C.LATIN1"

От
"James Pang (chaolpan)"
Дата:
The sorting order behavior is same ,right? 

-----Original Message-----
From: Laurenz Albe <laurenz.albe@cybertec.at> 
Sent: Thursday, March 9, 2023 4:30 PM
To: James Pang (chaolpan) <chaolpan@cisco.com>; pgsql-admin@lists.postgresql.org
Subject: Re: database collation "C" and "C.LATIN1"

On Thu, 2023-03-09 at 08:22 +0000, James Pang (chaolpan) wrote:
> We create one database with collate= “C.LATIN1”, any difference between “C” and “C.LATIN1” ?
> database encoding is “LATIN1”.
>  
>   oid  |        collname        | collencoding |   collcollate    |    
> collctype     | collversion
> -------+------------------------+--------------+------------------+------------------+-------------
>    950 | C                      |           -1 | C                | C                |
>  12328 | C.latin1               |            8 | C.latin1         | C.latin1         |

The difference is a technicality: "C" is encoding agnostic (-1) and can be used with any encoding, while "C.latin1" can
onlybe used with encoding LATIN1 (8).
 
The behavior is the same.

Yours,
Laurenz Albe

RE: database collation "C" and "C.LATIN1"

От
"James Pang (chaolpan)"
Дата:
Both follow  "C"  collate behavior ,right?  

-----Original Message-----
From: Laurenz Albe <laurenz.albe@cybertec.at> 
Sent: Thursday, March 9, 2023 4:30 PM
To: James Pang (chaolpan) <chaolpan@cisco.com>; pgsql-admin@lists.postgresql.org
Subject: Re: database collation "C" and "C.LATIN1"

On Thu, 2023-03-09 at 08:22 +0000, James Pang (chaolpan) wrote:
> We create one database with collate= “C.LATIN1”, any difference between “C” and “C.LATIN1” ?
> database encoding is “LATIN1”.
>  
>   oid  |        collname        | collencoding |   collcollate    |    
> collctype     | collversion
> -------+------------------------+--------------+------------------+------------------+-------------
>    950 | C                      |           -1 | C                | C                |
>  12328 | C.latin1               |            8 | C.latin1         | C.latin1         |

The difference is a technicality: "C" is encoding agnostic (-1) and can be used with any encoding, while "C.latin1" can
onlybe used with encoding LATIN1 (8).
 
The behavior is the same.

Yours,
Laurenz Albe

Re: database collation "C" and "C.LATIN1"

От
Laurenz Albe
Дата:
On Thu, 2023-03-09 at 08:37 +0000, James Pang (chaolpan) wrote:
> Both follow  "C"  collate behavior ,right? 

Right.

Yours,
Laurenz Albe



Re: database collation "C" and "C.LATIN1"

От
Tom Lane
Дата:
Laurenz Albe <laurenz.albe@cybertec.at> writes:
> On Thu, 2023-03-09 at 08:37 +0000, James Pang (chaolpan) wrote:
>> Both follow  "C"  collate behavior ,right?  

> Right.

There is another difference: "C" is a built-in collation, while
"C.latin1" must have been something that initdb made because
"locale -a" claimed it exists on your platform.  Postgres has
some optimizations built in for "C" (and its equivalent "POSIX")
that will not apply for "C.latin1".  So while they should be
behaviorally the same, "C.latin1" is likely to be slower.

            regards, tom lane