r23938 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23937‎ | r23938 | r23939 >
Date:07:00, 10 July 2007
Author:mkroetzsch
Status:old
Tags:
Comment:
More efficient subcategory resolution
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php
@@ -870,8 +870,7 @@
871871 $tmpnew='smw_newcats';
872872 $tmpres='smw_rescats';
873873
874 - /// TODO: check for empty $tmpnew to abort early
875 - /// TODO: avoid duplicate results
 874+ /// TODO: avoid duplicate results?
876875 for ($i=0; $i<$smwgIQSubcategoryInclusions; $i++) {
877876 $db->insertSelect($tmpres,
878877 array($cltable,$pagetable,$tmpnew),
@@ -880,14 +879,12 @@
881880 "$cltable.cl_to=$tmpnew.cat_name AND
882881 $pagetable.page_namespace=" . NS_CATEGORY . " AND
883882 $pagetable.page_id=$cltable.cl_from"), 'SMW::getCategoryTable');
884 - $db->insertSelect($tablename, array($tmpnew), array('cat_name' => 'cat_name'),
 883+ if ($db->affectedRows() == 0) { // no change, exit loop
 884+ continue;
 885+ }
 886+ $db->insertSelect($tablename, array($tmpres), array('cat_name' => 'cat_name'),
885887 '*', 'SMW::getCategoryTable');
886 - $db->insertSelect($tablename, array($tmpnew), array('cat_name' => 'cat_name'),
887 - '*', 'SMW::getCategoryTable');
888 - $db->query('DROP TABLE ' . $tmpnew, 'SMW::getCategoryTable'); // empty "new" table
889 - $db->query( 'CREATE TEMPORARY TABLE ' . $tmpnew . '
890 - ( cat_name VARCHAR(255) NOT NULL )
891 - TYPE=MEMORY', 'SMW::getCategoryTable' );
 888+ $db->query('TRUNCATE TABLE ' . $tmpnew, 'SMW::getCategoryTable'); // empty "new" table
892889 $tmpname = $tmpnew;
893890 $tmpnew = $tmpres;
894891 $tmpres = $tmpname;

Status & tagging log