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 Value | Result Units | Result Units Indicator |
---|---|---|
Up to 103 − 1 | picoseconds | ps |
Up to 106 − 1 | nanoseconds | ns |
Up to 109 − 1 | microseconds | us |
Up to 1012 − 1 | milliseconds | ms |
Up to 60×1012 − 1 | seconds | s |
Up to 3.6×1015 − 1 | minutes | min |
Up to 8.64×1016 − 1 | hours | h |
8.64×1016 and up | days | d |
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 | +--------+-----------+----------+---------+--------+-----------+--------+--------+