When the database has 10000 or so nodes, the database starts to slow down drastically and will run thousands of SQL queries. Note this behavior doesn't affect user 1, but only the other users.
...
SELECT nid as kid FROM relativity WHERE parent_nid = 7182
SELECT nid as kid FROM relativity WHERE parent_nid = 7183
SELECT nid as kid FROM relativity WHERE parent_nid = 7184
SELECT nid as kid FROM relativity WHERE parent_nid = 7185
SELECT nid as kid FROM relativity WHERE parent_nid = 7186
...
So I tried updating the _list_progeny() function, reducing the $too_many variable and changing the "==" operator to ">", like this, but no luck:
function _list_progeny($nids, $nid = 0, $too_many = 1)
{
if ($too_many > 100)
{
return;
}
$too_many += 1;
$kids = array();
$result = db_query("SELECT nid as kid FROM {relativity} WHERE parent_nid = %d", $nid);
while ($obj = db_fetch_object($result))
{
$kids[] = $obj->kid;
}
if ($kids)
{
drupal_set_message(print_r($kids, true)); //PRINT OUTPUT FOR DEBUGGING PURPOSES
$nids = array_merge($nids, $kids);
foreach ($kids AS $kid)
{
$nids = _list_progeny($nids, $kid, $too_many);
}
}
unset($kids);
return $nids;
}
The results of the following line of code are attached. (I just pulled out the HTML created by the print_r() command) :O
drupal_set_message(print_r($kids, true));
Because our database is stuck in SQL mud, any tips or suggestions on how to optimize this would be most helpful. Thanks :)
| Comment | File | Size | Author |
|---|---|---|---|
| error.txt | 214.47 KB | Mac Clemmens |