From b70967e3e6cf6e26dc3ed6e91eddadd7f91e3dbf Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 20 Aug 2013 09:49:47 -0700 Subject: [PATCH] Tweaked location of profiling in query() to split out the implicit BEGIN * This also should make the DBPerformance log look clearer. Change-Id: I98764647bbb19a5f130bd3d87488f32cb2825ea8 --- includes/db/Database.php | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/includes/db/Database.php b/includes/db/Database.php index 623010f2ea..0b2cc986b7 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -882,22 +882,7 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { * for a successful read query, or false on failure if $tempIgnore set */ public function query( $sql, $fname = __METHOD__, $tempIgnore = false ) { - $isMaster = !is_null( $this->getLBInfo( 'master' ) ); - if ( !Profiler::instance()->isStub() ) { - # generalizeSQL will probably cut down the query to reasonable - # logging size most of the time. The substr is really just a sanity check. - - if ( $isMaster ) { - $queryProf = 'query-m: ' . substr( DatabaseBase::generalizeSQL( $sql ), 0, 255 ); - $totalProf = 'DatabaseBase::query-master'; - } else { - $queryProf = 'query: ' . substr( DatabaseBase::generalizeSQL( $sql ), 0, 255 ); - $totalProf = 'DatabaseBase::query'; - } - - wfProfileIn( $totalProf ); - wfProfileIn( $queryProf ); - } + global $wgUser, $wgDebugDBTransactions; $this->mLastQuery = $sql; if ( !$this->mDoneWrites && $this->isWriteQuery( $sql ) ) { @@ -907,7 +892,6 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { } # Add a comment for easy SHOW PROCESSLIST interpretation - global $wgUser; if ( is_object( $wgUser ) && $wgUser->isItemLoaded( 'name' ) ) { $userName = $wgUser->getName(); if ( mb_strlen( $userName ) > 15 ) { @@ -931,7 +915,6 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { # is really used by application $sqlstart = substr( $sql, 0, 10 ); // very much worth it, benchmark certified(tm) if ( strpos( $sqlstart, "SHOW " ) !== 0 && strpos( $sqlstart, "SET " ) !== 0 ) { - global $wgDebugDBTransactions; if ( $wgDebugDBTransactions ) { wfDebug( "Implicit transaction start.\n" ); } @@ -940,6 +923,21 @@ abstract class DatabaseBase implements IDatabase, DatabaseType { } } + $isMaster = !is_null( $this->getLBInfo( 'master' ) ); + if ( !Profiler::instance()->isStub() ) { + # generalizeSQL will probably cut down the query to reasonable + # logging size most of the time. The substr is really just a sanity check. + if ( $isMaster ) { + $queryProf = 'query-m: ' . substr( DatabaseBase::generalizeSQL( $sql ), 0, 255 ); + $totalProf = 'DatabaseBase::query-master'; + } else { + $queryProf = 'query: ' . substr( DatabaseBase::generalizeSQL( $sql ), 0, 255 ); + $totalProf = 'DatabaseBase::query'; + } + wfProfileIn( $totalProf ); + wfProfileIn( $queryProf ); + } + # Keep track of whether the transaction has write queries pending if ( $this->mTrxLevel && !$this->mTrxDoneWrites && $this->isWriteQuery( $sql ) ) { $this->mTrxDoneWrites = true; -- 2.20.1