select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

CONFIGURATION / CLIENT CONNECTION DEFAULTS

client_encoding

Read PG 18 manual ↗

Sets the client-side encoding (character set).

Type
string
Context
user
Measured default
SQL_ASCII
Unit
Metadata snapshot
18

Definition PG 18 manual

Sets the client-side encoding (character set). The default is to use the database encoding. The character sets supported by the PostgreSQL server are described in Section 23.3.1.

Measured default history
Version intervalDefault
9.0 – 19SQL_ASCII
Analysis & operational context

Authored guidance from the GUC source snapshot; the version-specific manual above is the definition reference. View source ↗

How it works

client_encoding sets the client's character set encoding. PostgreSQL converts text between this encoding and the database encoding when a supported conversion exists; SQL_ASCII disables useful validation rather than identifying a real character set.

client_encoding is a USER-context setting. An authorized role can change it for a session, while ALTER ROLE or ALTER DATABASE can establish a default for future sessions.

It changes representation, parsing, or locale behavior at the client boundary rather than physical storage. Coordinate it with the other locale and formatting settings and with driver-native binary or typed protocols.

Operational considerations

Changing client_encoding in one session and assuming role defaults, database defaults, or other pooled sessions changed with it.

Assuming a presentation setting changes stored values or server-side type semantics.

Changing a role or database default without testing text-parsing clients, exports, and pooled sessions.

Using SQL_ASCII as if it were an encoding and allowing invalid byte sequences to cross the client boundary.

Workload guidance

OLAP: Pin client_encoding for export, reporting, and reproducible analytical jobs; prefer explicit SQL formatting when a file or API has a durable schema.

OLTP: Treat client_encoding as an application contract, not a performance knob. Standardize it per role or connection pool and keep wire formats explicit where clients parse text.

SMALL: Keep the upstream or locale-derived value unless a client requires another one. A smaller server gains no capacity from changing client_encoding.

Version history 4
  1. PG 16 → 17changed
  2. PG 13 → 14changed
  3. PG 9.5 → 9.6changed
  4. PG 9.0 → 9.1changed

Related entries

Further reading

Definition snapshot: english-manuals:246c484441044e0259e601064aa… · English manual source