Daniel Kinzler has uploaded a new change for review.

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

Change subject: Use eu_row_id when touching usage entries.
......................................................................

Use eu_row_id when touching usage entries.

Rationale: reduce lock retention time on the master db.

Bug: T107319
Change-Id: Iedacc0cb0d2e2c13b8add0cdae27435fc84aeb41
---
M client/includes/Usage/Sql/EntityUsageTable.php
1 file changed, 19 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/17/232917/1

diff --git a/client/includes/Usage/Sql/EntityUsageTable.php 
b/client/includes/Usage/Sql/EntityUsageTable.php
index a9ccdd9..e314d95 100644
--- a/client/includes/Usage/Sql/EntityUsageTable.php
+++ b/client/includes/Usage/Sql/EntityUsageTable.php
@@ -94,18 +94,31 @@
                        ), LIST_AND );
                }
 
-               // XXX: Do we need batching here? List pages may be using 
hundreds of entities...
-               $this->connection->update(
+               // Collect affected row IDs, so we can use them for an
+               // efficient update query on the master db.
+               $rowIds = $db->selectFieldValues(
                        $this->tableName,
-                       array(
-                               'eu_touched' => wfTimestamp( TS_MW, $touched ),
-                       ),
+                       'eu_row_id',
                        array(
                                'eu_page_id' => (int)$pageId,
-                               $this->connection->makeList( $usageConditions, 
LIST_OR )
+                               $db->makeList( $usageConditions, LIST_OR )
                        ),
                        __METHOD__
                );
+
+               if ( !empty( $rowIds ) ) {
+                       // XXX: Do we need batching here? List pages may be 
using hundreds of entities...
+                       $db->update(
+                               $this->tableName,
+                               array(
+                                       'eu_touched' => wfTimestamp( TS_MW, 
$touched ),
+                               ),
+                               array(
+                                       'eu_row_id' => $rowIds
+                               ),
+                               __METHOD__
+                       );
+               }
        }
 
        /**

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iedacc0cb0d2e2c13b8add0cdae27435fc84aeb41
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>

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

Reply via email to