During nodeapi for insert/update operations, _tracker2_add() is invoked to record tracker data, and here the {node} table is queries to obtain the node status. However, this is already available from the $node object passed to nodeapi, so this query is not really required in that case.

I think $node->status could be passed as an additional argument to _tracker2_add(), and perform the query against the {node} table, only when the $status argument is not passed.

Comments

markus_petrux’s picture

Title: Avoid one query during nodeapi for insert/update operations » Avoid one query during nodeapi for insert/update/delete operations

hmm... and the same logic could also be applied to _tracker2_remove(). When invoked from nodeapi('delete'), $node->status could be passed as an additional argument, and this could be used to avoid a query in _tracker2_remove() because when $status would be passed to _tracker2_remove() that means the node is being deleted, so there's no need to check if it exists.

[EDIT] In fact, during nodeapi('delete') there's no need to invoke _tracker2_remove() because the following is enough, I think:

  db_query("DELETE FROM {tracker2_node} WHERE nid = %d", $node->nid);
  db_query("DELETE FROM {tracker2_user} WHERE nid = %d", $node->nid);

So here we can save a query to the {node} table, and an invocation to _tracker2_remove(). :)