Bug #97558 Add function (like sys.format_time) to convert TIMER_START to timestamp
Submitted: 8 Nov 2019 12:03 Modified: 8 Nov 2019 13:57
Reporter: Valeriy Kravchuk Email Updates:
Status: Verified Impact on me:
Category:MySQL Server: SYS Schema Severity:S4 (Feature request)
Version:5.7+ OS:Any
Assigned to: CPU Architecture:Any
Tags: missing manual, timer_start

[8 Nov 2019 12:03] Valeriy Kravchuk
It would be really useful to have a way to transalate TIMER_START and similar column (measured in picoseconds since some time after server startup) to a timetstamp (with data and time) that can be related to error log entires, I_S tables etc.

We have sys.format_time() function and the one I ask about may be similar, to be used in context more or less like this:

mysql> select event_id, @ts := date_add(@start, interval timer_start/10
00000000000 second) as ts, sql_text, now(), timediff(now(), @ts) from performance_schema.events_statements_current\G
*************************** 1. row ***************************
            event_id: 657
                  ts: 2019-11-03 18:24:00.501654
            sql_text: select event_id, @ts := date_add(@start, interval timer_start/1000000000000 second) as ts, sql_text, now(), timediff(now(), @ts) from performance_schema.events_statements_current
               now(): 2019-11-03 18:24:05
timediff(now(), @ts): 00:00:04.498346
1 row in set (0.002 sec)

where @start is somehow determined timestamp of counter start.

As my example above shows, simple calculation may start to differ notably with uptime. So, something better is needed.

How to repeat:
Try to conver TIMER_START column from performance_schema into the real timestamp reliably and correctly.

Suggested fix:
If there is no reliable way to relate TIMER_START to the real life timestamp of event, please, document this as a clear limitation in the manual.
[8 Nov 2019 13:57] MySQL Verification Team
Hi Mr. Kravchuk,

Thank you for your feature request.

I think that your request is fully justified.

Verified as. a feature request.