Further fix to profiling order for DBPerformance log
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 22 Aug 2013 21:44:30 +0000 (14:44 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 22 Aug 2013 21:45:11 +0000 (14:45 -0700)
* Make sure transactionWritingIn() gets called before the profileIn()
  so the first write query shows up

Change-Id: Ife504651f6fe33f1360e817bcb05afc02f4075a5

includes/db/Database.php

index 0b2cc98..8e1f93f 100644 (file)
@@ -923,6 +923,12 @@ abstract class DatabaseBase implements IDatabase, DatabaseType {
                        }
                }
 
+               # Keep track of whether the transaction has write queries pending
+               if ( $this->mTrxLevel && !$this->mTrxDoneWrites && $this->isWriteQuery( $sql ) ) {
+                       $this->mTrxDoneWrites = true;
+                       Profiler::instance()->transactionWritingIn( $this->mServer, $this->mDBname );
+               }
+
                $isMaster = !is_null( $this->getLBInfo( 'master' ) );
                if ( !Profiler::instance()->isStub() ) {
                        # generalizeSQL will probably cut down the query to reasonable
@@ -938,12 +944,6 @@ abstract class DatabaseBase implements IDatabase, DatabaseType {
                        wfProfileIn( $queryProf );
                }
 
-               # Keep track of whether the transaction has write queries pending
-               if ( $this->mTrxLevel && !$this->mTrxDoneWrites && $this->isWriteQuery( $sql ) ) {
-                       $this->mTrxDoneWrites = true;
-                       Profiler::instance()->transactionWritingIn( $this->mServer, $this->mDBname );
-               }
-
                if ( $this->debug() ) {
                        static $cnt = 0;