application_name
Read PG 18 manual ↗The application_name can be any string of less than NAMEDATALEN characters (64 characters in a standard build).
- Type
- string
- Context
- user
- Measured default
- Empty string
- Unit
- —
- Metadata snapshot
- 18
Definition PG 18 manual
The application_name can be any string of less than NAMEDATALEN characters (64 characters in a standard build). It is typically set by an application upon connection to the server. The name will be displayed in the pg_stat_activity view and included in CSV log entries. It can also be included in regular log entries via the log_line_prefix parameter. Only printable ASCII characters may be used in the application_name value. Other characters are replaced with C-style hexadecimal escapes.
Measured default history
| Version interval | Default |
|---|---|
| 9.0 – 19 | Empty string |
Authored guidance from the GUC source snapshot; the version-specific manual above is the definition reference. View source ↗
How it works
application_name is client-supplied session metadata, usually set in the startup packet or later with SET. It appears in pg_stat_activity and CSV logs and can be inserted into text logs with the %a escape in log_line_prefix.
The value is shorter than NAMEDATALEN bytes (64 characters in a standard build). PostgreSQL permits printable ASCII; other characters are rendered as C-style hexadecimal escapes. Truncation and escaping mean log consumers must not assume the displayed value exactly matches an application's original string.
It is a USER-context label and is not authenticated identity: any authorized client can claim a misleading value and a pooled session can retain or overwrite it. Correlate it with authenticated user, database, session ID, remote endpoint, and controlled pool checkout/reset behavior.
Operational considerations
Treating application_name as authenticated identity or using it alone for authorization, billing, or audit attribution.
Exceeding NAMEDATALEN and silently losing distinguishing suffixes through truncation.
Assuming arbitrary Unicode is preserved rather than escaped to printable C-style hexadecimal sequences.
Leaking secrets or creating unbounded cardinality in logs and pg_stat_activity, or failing to reset the value in a connection pool.
Workload guidance
OLAP: Set a stable job or tool family label and place run-specific high-cardinality identity elsewhere. Correlate long analytical sessions with authenticated role and session ID.
OLTP: Require each service and pooler to set a short, stable, non-secret application_name at checkout and reset it before reuse. Use controlled naming conventions, but never authorize or audit solely from this value.
SMALL: Keep labels compact and useful; node size is irrelevant. Avoid embedding tenant IDs, tokens, SQL, or unbounded request identifiers in a 64-character client-controlled field.
Version history 1
- PG 15 → 16changed
Related entries
Further reading
Definition snapshot: english-manuals:1598066dd2ba5388e6cc8f100ed… · English manual source