Hi,
I am pretty sure that the hosting_task module function hosting_task_fetch_tasks can be made more efficient in the following two ways ...

1) The function includes this SQL ...

SELECT n.nid, t.task_type, t.task_status
FROM {node} n LEFT JOIN {hosting_task} t ON n.vid = t.vid
WHERE n.type = 'task' AND t.rid = %d
ORDER BY t.task_status ASC, n.changed DESC

An Inner join will generate records with NULL values for some columns, when there is no match on the join condition. This query, though, has additional constraints ( t.rid = %d ) that remove any rows with such NULL records from the result set. As a result, this SQL does not have to be an outer join. It could be an inner join, which is simpler.

As a result the following simpler SQL could be used ...

SELECT n.nid, t.task_type, t.task_status
FROM {node} n, {hosting_task} t
WHERE n.vid = t.vid AND n.type = 'task' AND t.rid = %d
ORDER BY t.task_status ASC, n.changed DESC

2) The following line is included twice but only needs to be run once:

$tasks = hosting_available_tasks($node->type);

It this strikes folks as reasonable I can submit a patch.

thanks,
Ken Wolf

Comments

Ken Wolf’s picture

Status: Active » Closed (fixed)

typos, sorry, I created a new ticket with the correct wording