Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php |
— | — | @@ -845,17 +845,19 @@ |
846 | 846 | * wrt. the category table. |
847 | 847 | */ |
848 | 848 | protected function getCategoryTable($catname, &$db) { |
849 | | - if (array_key_exists($catname, SMWSQLStore::$m_categorytables)) { |
850 | | - return SMWSQLStore::$m_categorytables[$catname]; |
851 | | - } |
852 | | - |
853 | 849 | global $wgDBname, $smwgIQSubcategoryInclusions; |
854 | 850 | |
855 | | - // Create multiple temporary tables for recursive computation |
856 | 851 | $tablename = 'cats' . SMWSQLStore::$m_tablenum++; |
857 | 852 | $db->query( 'CREATE TEMPORARY TABLE ' . $wgDBname . '.' . $tablename . |
858 | 853 | '( cat_name VARCHAR(255) NOT NULL ) |
859 | 854 | TYPE=MEMORY', 'SMW::getCategoryTable' ); |
| 855 | + if (array_key_exists($catname, SMWSQLStore::$m_categorytables)) { // just copy known result |
| 856 | + $db->insertSelect($tablename, array(SMWSQLStore::$m_categorytables[$catname]), |
| 857 | + array('cat_name' => 'cat_name'),'*', 'SMW::getCategoryTable'); |
| 858 | + return $tablename; |
| 859 | + } |
| 860 | + |
| 861 | + // Create multiple temporary tables for recursive computation |
860 | 862 | $db->query( 'CREATE TEMPORARY TABLE smw_newcats |
861 | 863 | ( cat_name VARCHAR(255) NOT NULL ) |
862 | 864 | TYPE=MEMORY', 'SMW::getCategoryTable' ); |
— | — | @@ -1011,8 +1013,7 @@ |
1012 | 1014 | global $smwgIQSubcategoryInclusions; |
1013 | 1015 | if ($smwgIQSubcategoryInclusions > 0) { |
1014 | 1016 | $ct = $this->getCategoryTable($description->getCategory()->getDBKey(), $db); |
1015 | | - $ctalias = 'cl' . SMWSQLStore::$m_tablenum++; |
1016 | | - $from .= " INNER JOIN $ct AS $ctalias ON $ctalias.cat_name=" . $curtables['CATS'] . '.cl_to'; |
| 1017 | + $from .= " INNER JOIN $ct ON $ct.cat_name=" . $curtables['CATS'] . '.cl_to'; |
1017 | 1018 | } else { |
1018 | 1019 | $where .= $curtables['CATS'] . '.cl_to=' . $db->addQuotes($description->getCategory()->getDBKey()); |
1019 | 1020 | } |
— | — | @@ -1082,7 +1083,9 @@ |
1083 | 1084 | foreach ($description->getDescriptions() as $subdesc) { |
1084 | 1085 | /// TODO: this is not optimal -- we drop more table aliases than needed, but its hard to find out what is feasible in recursive calls ... |
1085 | 1086 | $nexttables = array(); |
1086 | | - if (array_key_exists('PAGE',$curtables)) { |
| 1087 | + // pull in page to prevent every child description pulling it seperately! |
| 1088 | + /// TODO: willl be obsolete when PREVREL provides page indices |
| 1089 | + if ($this->addInnerJoin('PAGE', $from, $db, $curtables)) { |
1087 | 1090 | $nexttables['PAGE'] = $curtables['PAGE']; |
1088 | 1091 | } |
1089 | 1092 | if (array_key_exists('PREVREL',$curtables)) { |