EBernhardson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/214054
Change subject: Pre-cache title information about search resultset
......................................................................
Pre-cache title information about search resultset
For each and every search result mediawiki is going out and making a
database query to collect information about these objects. Instead
build up a LinkBatch when constructing the ResultSet to batch together
into a single query.
Change-Id: Ic0cb78c7fc6dab46fce99d51e42f59dac3438c02
---
M includes/Search/ResultSet.php
1 file changed, 16 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch
refs/changes/54/214054/1
diff --git a/includes/Search/ResultSet.php b/includes/Search/ResultSet.php
index a1839fc..3f498f6 100644
--- a/includes/Search/ResultSet.php
+++ b/includes/Search/ResultSet.php
@@ -2,6 +2,7 @@
namespace CirrusSearch\Search;
use \CirrusSearch\Searcher;
+use \LinkBatch;
use \SearchResultSet;
/**
@@ -33,6 +34,7 @@
$this->hits = $res->count();
$this->totalHits = $res->getTotalHits();
$this->interwikiPrefix = $interwiki;
+ $this->preCacheContainedTitles();
$suggestion = $this->findSuggestion();
if ( $suggestion && !
$this->resultContainsFullyHighlightedMatch() ) {
$this->suggestionQuery = $suggestion[ 'text' ];
@@ -101,6 +103,20 @@
return false;
}
+ private function preCacheContainedTitles() {
+ $lb = new LinkBatch;
+ foreach ( $this->result->getResults() as $result ) {
+ $title = Title::makeTitle( $result->namespace,
$result->title, '', $this->interwikiPrefix );
+ if ( $title ) {
+ $lb->addObj( $title );
+ }
+ }
+ if ( !$lb->isEmpty() ) {
+ $lb->setCaller( __METHOD__ );
+ $lb->execute();
+ }
+ }
+
public function getTotalHits() {
return $this->totalHits;
}
--
To view, visit https://gerrit.wikimedia.org/r/214054
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic0cb78c7fc6dab46fce99d51e42f59dac3438c02
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits