Dunno if it is just me, but
PHP Code:
$products = $db->query_read("
SELECT pr.*
,count(DISTINCT pl.pluginid) AS plugin
,count(DISTINCT ph.phraseid) AS phrase
,count(DISTINCT templateid) AS template
# ,count(DISTINCT se.varname) AS setting
FROM " . TABLE_PREFIX . "product AS pr
LEFT JOIN " . TABLE_PREFIX . "plugin AS pl ON (pl.product = pr.productid)
LEFT JOIN " . TABLE_PREFIX . "phrase AS ph ON (ph.product = pr.productid)
LEFT JOIN " . TABLE_PREFIX . "template AS te ON (te.product = pr.productid)
# LEFT JOIN " . TABLE_PREFIX . "setting AS se ON (se.product = pr.productid)
GROUP BY productid
ORDER BY title");
while ($product = $db->fetch_array($products))
keeps killing my Server. This Query takes over 1 Minute to execute and while it does run, the machine is almost unusable - CPU 100%.
Therefore I replaced that Code with
PHP Code:
$productq = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "product ORDER BY title");
while ($product = $db->fetch_array($productq))
{
$products["$product[productid]"] = $product;
$products["$product[productid]"]['plugin'] = 0;
$products["$product[productid]"]['phrase'] = 0;
$products["$product[productid]"]['template'] = 0;
$products["$product[productid]"]['setting'] = 0;
}
$pluginq = $db->query_read("SELECT product, COUNT(pluginid) AS plugin FROM " . TABLE_PREFIX . "plugin WHERE product != 'vbulletin' GROUP BY product");
while ($plugin = $db->fetch_array($pluginq))
{
$products["$plugin[product]"]['plugin'] = $plugin['plugin'];
}
$phraseq = $db->query_read("SELECT product, COUNT(phraseid) AS phrase FROM " . TABLE_PREFIX . "phrase WHERE languageid=-1 AND product != '' AND product != 'vbulletin' GROUP BY product");
while ($phrase = $db->fetch_array($phraseq))
{
$products["$phrase[product]"]['phrase'] = $phrase['phrase'];
}
$templateq = $db->query_read("SELECT product, COUNT(templateid) AS template FROM " . TABLE_PREFIX . "template WHERE styleid=-1 AND product != '' AND product != 'vbulletin'GROUP BY product");
while ($template = $db->fetch_array($templateq))
{
$products["$template[product]"]['template'] = $template['template'];
}
$settingq = $db->query_read("SELECT product, COUNT(varname) AS setting FROM " . TABLE_PREFIX . "setting WHERE product != '' AND product != 'vbulletin' GROUP BY product");
while ($setting = $db->fetch_array($settingq))
{
$products["$setting[product]"]['setting'] = $setting['setting'];
}
foreach ($products AS $product)
This shows the Results instantly.