Understanding the FORMAT_PICO_TIME() Function in MySQL

In MySQL, format_pico_time() is a Performance Schema function that converts a numeric Performance Schema latency or wait time in picoseconds into a human-readable format. It returns a string consisting of a value and a units indicator.

Syntax

The syntax goes like this:

FORMAT_PICO_TIME(time_val)

Where time_val is a numeric Performance Schema latency or wait time in picoseconds.

Resulting Unit Indicator

As mentioned, the format_pico_time() function returns a string consisting of a value and a units indicator.

The units indicator depends on the size of the time-value argument as shown in the following table.

Argument ValueResult UnitsResult Units Indicator
Up to 103 − 1picosecondsps
Up to 106 − 1nanosecondsns
Up to 109 − 1microsecondsus
Up to 1012 − 1millisecondsms
Up to 60×1012 − 1secondss
Up to 3.6×1015 − 1minutesmin
Up to 8.64×1016 − 1hoursh
8.64×1016 and updaysd

Example

Here’s an example to demonstrate:

SELECT format_pico_time(847002);

Result:

847.00 ns

Here’s another example that demonstrates how different values affect the result:

SELECT 
    format_pico_time(847) AS ps,
    format_pico_time(847002) AS ns,
    format_pico_time(84700212) AS us,
    format_pico_time(8470021234) AS ms,
    format_pico_time(8470021234567) AS s,
    format_pico_time(847002123456789) AS min,
    format_pico_time(8470021234567898) AS h,
    format_pico_time(847002123456789876) AS d;

Result:

+--------+-----------+----------+---------+--------+-----------+--------+--------+
| ps     | ns        | us       | ms      | s      | min       | h      | d      |
+--------+-----------+----------+---------+--------+-----------+--------+--------+
| 847 ps | 847.00 ns | 84.70 us | 8.47 ms | 8.47 s | 14.12 min | 2.35 h | 9.80 d |
+--------+-----------+----------+---------+--------+-----------+--------+--------+