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 outer 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

Anonymous’s picture

Status: Active » Needs work

Patches are welcome!

Steven Jones’s picture

Version: 6.x-0.4-alpha3 » 6.x-2.x-dev
Status: Needs work » Fixed

Thanks! I've fixed both those in 6.x-2.x

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit 08e4f03 on 6.x-2.x, dev-ssl-ip-allocation-refactor, dev-1205458-move_sites_out_of_platforms, 7.x-3.x, dev-588728-views-integration, dev-1403208-new_roles, dev-helmo-3.x by Steven Jones:
    Issue #782440 by Ken Wolf: Hosting_task() module function...

  • Commit 08e4f03 on 6.x-2.x, dev-ssl-ip-allocation-refactor, dev-1205458-move_sites_out_of_platforms, 7.x-3.x, dev-588728-views-integration, dev-1403208-new_roles, dev-helmo-3.x by Steven Jones:
    Issue #782440 by Ken Wolf: Hosting_task() module function...