0

I implemented hook_cron() to delete nodes older than 30 days using node_delete function. Tracing the performance displays this:

2015-07-06 21:28:49 Drupal watchdog ApCleanup::node_delete|/fpe/article||0||Node ID 423466 has been deleted [1.1173 secs] request_id="v-b8288e7a-2415-11e5-b14b-22000aeb06a5"

A single node deletion takes 1.1 sec. What is the most efficient way to delete the (2075546) nodes using hook_cron() and the node_delete_multiple function?

  • I'm using the node_revision_delete module, but I wouldn't call it fast. – Ryre Jul 7 '15 at 19:26
0

I would not recommend using Cron for this task.Since you have so many nodes it would always time out. Your better off using Drush and the Delete All module.

Or if you're fully purging all your nodes for instance I have written an SQL script before I can invoke with Drush which uses the sql truncate command to remove all data from Fields of a content type and then does a delete all from node and node_revisions for the given content type, and url aliases -- etc. Using SQL makes such a task take very little time for hundreds of thousands of nodes.

EDIT:

The Delete All admin UI has options for a quick delete that uses sql JOINs and not node_delete. See the admin form code: http://cgit.drupalcode.org/delete_all/tree/delete_all.module#n71

I suggest you install and try using the module.

  • Am setting up the cron for daily basis, to delete 30 days old nodes every day. delete_all module is using node_delete function, which I already implemented and not worth..... am looking something BulkDelete , where nodeids should delete in batch process and use node_delete_multiple – athakhan Jul 7 '15 at 15:18
  • @athakhan See my edit please – tenken Jul 7 '15 at 15:51
  • Thanks... Use the quick node delete method to get around this problem. This method deletes directly from the database, skipping the extra php processing. The downside is that it can miss related tables that are normally handled by module hook_delete ( like revisions , other content fields) – athakhan Jul 7 '15 at 16:18
  • How about this module ? drupal.org/project/bulkdelete – athakhan Jul 7 '15 at 16:19
  • The batch API can be slow because the page refreshes you see on the screen actually must bootstrap Drupal fully each time. This adds a significant amount of overhead to whatever action you are trying to perform over time. While quick may miss related tables -- that's why i recommend you write your own SQL file to delete whatever you need as-needed. goodluck. – tenken Jul 7 '15 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.