select open change scope Open full search

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

CONFIGURATION / CLIENT CONNECTION DEFAULTS

extra_float_digits

Read PG 18 manual ↗

This parameter adjusts the number of digits used for textual output of floating-point values, including float4, float8, and geometric data types.

Type
integer
Context
user
Measured default
1
Unit
Metadata snapshot
18

Definition PG 18 manual

This parameter adjusts the number of digits used for textual output of floating-point values, including float4, float8, and geometric data types.

If the value is 1 (the default) or above, float values are output in shortest-precise format; see Section 8.1.3. The actual number of digits generated depends only on the value being output, not on the value of this parameter. At most 17 digits are required for float8 values, and 9 for float4 values. This format is both fast and precise, preserving the original binary float value exactly when correctly read. For historical compatibility, values up to 3 are permitted.

If the value is zero or negative, then the output is rounded to a given decimal precision. The precision used is the standard number of digits for the type (FLT_DIG or DBL_DIG as appropriate) reduced according to the value of this parameter. (For example, specifying -1 will cause float4 values to be output rounded to 5 significant digits, and float8 values rounded to 14 digits.) This format is slower and does not preserve all the bits of the binary float value, but may be more human-readable.

Note

The meaning of this parameter, and its default value, changed in PostgreSQL 12; see Section 8.1.3 for further discussion.

Measured default history
Version intervalDefault
9.0 – 110
12 – 191
Analysis & operational context

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

How it works

extra_float_digits sets the number of digits displayed for floating-point values. This affects real, double precision, and geometric data types. A zero or negative parameter value is added to the standard number of digits (FLT_DIG or DBL_DIG as appropriate). Any value greater than zero selects precise output mode. Since PostgreSQL 12, positive values select shortest-precise output; zero and negative values request rounded legacy output and can lose round-trip fidelity.

extra_float_digits 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 extra_float_digits 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.

Carrying pre-12 assumptions forward even though positive values now select shortest-precise output.

Workload guidance

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

OLTP: Treat extra_float_digits 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 extra_float_digits.

Version history 1
  1. PG 11 → 12changed

Related entries

Further reading

Definition snapshot: english-manuals:528020eb029d5220a5d4956a4a2… · English manual source