Aaron Schulz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/80051


Change subject: Tweaked location of profiling in query() to split out the 
implicit BEGIN
......................................................................

Tweaked location of profiling in query() to split out the implicit BEGIN

* This also should make the DBPerformance log look clearer.

Change-Id: I98764647bbb19a5f130bd3d87488f32cb2825ea8
---
M includes/db/Database.php
1 file changed, 16 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/51/80051/1

diff --git a/includes/db/Database.php b/includes/db/Database.php
index 623010f..0b2cc98 100644
--- a/includes/db/Database.php
+++ b/includes/db/Database.php
@@ -882,22 +882,7 @@
         *     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 @@
                }
 
                # 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 @@
                        # 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 @@
                        }
                }
 
+               $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;

-- 
To view, visit https://gerrit.wikimedia.org/r/80051
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I98764647bbb19a5f130bd3d87488f32cb2825ea8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to