Configuration parameter

extra_float_digits — PostgreSQL configuration parameter

Category Client Connection Defaults

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

At a glance

Property Value
Parameter extra_float_digits
Category Client Connection Defaults
Default (see documentation)
Value type integer
Change scope Per-session (SET)
Available in PostgreSQL 12, 13, 14, 15, 16, 17, 18, 19 (added in 12)

What it does

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

(Description quoted from the official PostgreSQL documentation.)

How to apply a change

Can be set per session with SET, per role/database with ALTER ROLE/DATABASE ... SET, or globally in postgresql.conf.

Inspect the current value and source with SHOW extra_float_digits; or SELECT name, setting, unit, context, source FROM pg_settings WHERE name = 'extra_float_digits';.

Tuning guidance

This sets a session default (locale, formatting, search path or transaction behaviour) rather than a performance knob. Set it per role or database with ALTER ROLE/DATABASE ... SET so the right default follows the right workload, and prefer setting it explicitly in the application for behaviour the query results depend on.

Reference

PostgreSQL documentation — extra_float_digits.

Keep going

Related & next steps

Was this helpful?

← All configuration parameters