[TASK] Performance improvement on indexing process
[Packages/TYPO3.CMS.git] / typo3 / sysext / indexed_search / Classes / Indexer.php
index c964a51..4cd8fb6 100644 (file)
@@ -1993,18 +1993,25 @@ class Indexer {
         */
        public function submitWords($wordList, $phash) {
                if (\TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::isTableUsed('index_rel')) {
+                       $stopWords = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('wid', 'index_words', 'is_stopword != 0', '', '', '', 'wid');
+
                        $GLOBALS['TYPO3_DB']->exec_DELETEquery('index_rel', 'phash=' . (int)$phash);
+                       $fields = array('phash', 'wid', 'count', 'first', 'freq', 'flags');
+                       $rows = array();
                        foreach ($wordList as $val) {
-                               $insertFields = array(
-                                       'phash' => (int)$phash,
-                                       'wid' => (int)$val['hash'],
-                                       'count' => (int)$val['count'],
-                                       'first' => (int)$val['first'],
-                                       'freq' => $this->freqMap($val['count'] / $this->wordcount),
-                                       'flags' => $val['cmp'] & $this->flagBitMask
+                               if (isset($stopWords[$val['hash']])) {
+                                       continue;
+                               }
+                               $rows[] = array(
+                                       (int)$phash,
+                                       (int)$val['hash'],
+                                       (int)$val['count'],
+                                       (int)$val['first'],
+                                       $this->freqMap($val['count'] / $this->wordcount),
+                                       $val['cmp'] & $this->flagBitMask
                                );
-                               $GLOBALS['TYPO3_DB']->exec_INSERTquery('index_rel', $insertFields);
                        }
+                       $GLOBALS['TYPO3_DB']->exec_INSERTmultipleRows('index_rel', $fields, $rows);
                }
        }