Bug #99815 | Insist on using System.nanoTime() to measure elapsed time | ||
---|---|---|---|
Submitted: | 9 Jun 2020 3:01 | Modified: | 9 Jun 2020 4:21 |
Reporter: | Yanming Zhou (OCA) | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | Connector / J | Severity: | S3 (Non-critical) |
Version: | 8.0.x | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[9 Jun 2020 3:01]
Yanming Zhou
[9 Jun 2020 3:22]
Yanming Zhou
Then there is a bug here, executeTime is in nanos if JDK is 1.5 or later, slowQueryThresholdMillis is always in ms, then all queries will be treat as slow query. https://github.com/mysql/mysql-connector-j/blob/dbd865c9fc68701efc70197ea1e65002520bed91/s...
[9 Jun 2020 4:21]
MySQL Verification Team
Hello Yanming Zhou, Thank you for the report and feedback. regards, Umesh
[16 Jun 2020 23:52]
Filipe Silva
Note that `useNanosForElapsedTime` is "false" by default. All seems to work fine if you don't set it to "true". You are right, though. Using nanos really breaks some of the slow query logging features. Regarding `Query.getExecuteTime()` returning nanos or millis, I'd say this is debatable question. It makes sense to me that you get different units depending on the value you set in `useNanosForElapsedTime`. Thanks for your interest in Connector/J and MySQL.