* [refac] use SHOW PROFILES to get performance information of myslq when user can't access the performance_schema database.
This commit is contained in:
+10
-10
@@ -1875,17 +1875,17 @@ class baseDAO
|
||||
$performanceSwitch = $performanceSchema->Value ?? 'OFF';
|
||||
if($performanceSwitch == 'ON')
|
||||
{
|
||||
$profiles = $this->select('t1.EVENT_ID AS Query_ID, TRUNCATE(t1.TIMER_WAIT/1000000000000,6) AS Duration, t1.SQL_TEXT AS Query')
|
||||
->from('performance_schema.events_statements_history_long')->alias('t1')
|
||||
->leftJoin('performance_schema.threads')->alias('t2')->on('t1.THREAD_ID=t2.THREAD_ID')
|
||||
->where('t2.PROCESSLIST_ID=CONNECTION_ID()')
|
||||
->orderBy('EVENT_ID')
|
||||
->fetchAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
$profiles = $this->query('SHOW PROFILES')->fetchAll();
|
||||
try
|
||||
{
|
||||
$sql = "SELECT t1.EVENT_ID AS Query_ID, TRUNCATE(t1.TIMER_WAIT/1000000000000,6) AS Duration, t1.SQL_TEXT AS Query FROM performance_schema.events_statements_history_long AS t1 LEFT JOIN performance_schema.threads AS t2 ON t1.THREAD_ID=t2.THREAD_ID wHeRe t2.PROCESSLIST_ID=CONNECTION_ID() oRdEr bY EVENT_ID";
|
||||
$profiles = $this->dbh->query($sql)->fetchAll();
|
||||
}
|
||||
catch(PDOException $e)
|
||||
{
|
||||
$profiles = $this->query('SHOW PROFILES')->fetchAll();
|
||||
}
|
||||
}
|
||||
if(empty($profiles)) $profiles = $this->query('SHOW PROFILES')->fetchAll();
|
||||
|
||||
foreach($profiles as $profile)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user