Node delete performance issue I am using below code to delete all unregistered users node.
But it takes very long time to execute node_delete function.I have around 5000 records of users in node table.
How can I improve the performance of node_delete() function?

$query_node = db_query("SELECT n.nid FROM node n,status s WHERE s.entity_id = n.nid  AND type = 'employees' AND s.field_employee_status_value = '2' AND n.status = '1'");               
$result_node = $query_node-&gt;fetchAll();

foreach($result_node as $node)
{
    $nid = $node-&gt;nid;
    // $node id , which you want to delete;
    node_delete($nid);                              
}
Two appropriate options:


Use node_delete_multiple function instead of the node_delete(). I guess you need to do this only once, so this might be a faster solution if your server can execute the whole process at once (ie enough memory, not too many fields/modules, etc.).

$query_node = db_query("SELECT n.nid FROM node n,status s WHERE s.entity_id = n.nid  AND type = 'employees' AND s.field_employee_status_value = '2' AND n.status = '1'");               
$result_node = $query_node-&gt;fetchAll();

$nids = array();
foreach($result_node as $node) {
  $nids[] = $node-&gt;nid;
}
// Delete everything at once.
node_delete_multiple($nids);

You can also use Administration Views with Views Bulk Operations. You can filter the nodes based on what you need and then perform operations on all rows. This will process the deletion as a batch process. Downside is that you might need to install 2 additional modules if you don't have them already.