Title: LSCWP Database
Last modified: March 4, 2025

---

# LSCWP Database

 *  Resolved [carvol](https://wordpress.org/support/users/carvol/)
 * (@carvol)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/lscwp-database/)
 * Can someone help me to manage by cron, “Clean All” function for Database?
   I’ve
   found solution for cache, to purge all, but for DB – can’t.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Flscwp-database%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Support [qtwrk](https://wordpress.org/support/users/qtwrk/)
 * (@qtwrk)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/lscwp-database/#post-18340926)
 * unfortunately it doesn’t have option to cron it 🙁
 *  Thread Starter [carvol](https://wordpress.org/support/users/carvol/)
 * (@carvol)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/lscwp-database/#post-18340950)
 * Maybe, there is a way, to make a file whith script, that will make the same, 
   as i push the button “Clean All”?
 *  Plugin Support [qtwrk](https://wordpress.org/support/users/qtwrk/)
 * (@qtwrk)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/lscwp-database/#post-18343656)
 *     ```wp-block-code
       <?phprequire('./wp-load.php');global $wpdb;$wpdb->query("DELETE a FROM $wpdb->postmeta a LEFT JOIN $wpdb->posts b ON b.ID = a.post_id WHERE b.post_type = 'revision'");$wpdb->query("DELETE FROM $wpdb->posts WHERE post_type = 'revision'");$wpdb->query("DELETE a FROM $wpdb->postmeta a LEFT JOIN $wpdb->posts b ON b.ID = a.post_id WHERE b.ID IS NULL");$wpdb->query("DELETE FROM $wpdb->posts WHERE post_status = 'auto-draft'");$wpdb->query("DELETE FROM $wpdb->posts WHERE post_status = 'trash'");$wpdb->query("DELETE FROM $wpdb->comments WHERE comment_approved = 'spam'");$wpdb->query("DELETE FROM $wpdb->comments WHERE comment_approved = 'trash'");$wpdb->query("DELETE FROM $wpdb->comments WHERE comment_type = 'trackback' OR comment_type = 'pingback'");$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_timeout%' AND option_value < " . time());$wpdb->query("DELETE FROM $wpdb->options WHERE option_name LIKE '%\\_transient\\_%'");$result = $wpdb->get_results("SELECT table_name, DATA_FREE FROM information_schema.tables WHERE TABLE_SCHEMA = '" . DB_NAME . "' and ENGINE <> 'InnoDB' and DATA_FREE > 0");if ($result) {    foreach ($result as $row) {        $wpdb->query('OPTIMIZE TABLE ' . $row->table_name);    }}echo "done";
       ```
   
 * I extracted query from plugin , please note this is best-effort support , use
   it at your own risk and suggest to perform a backup and test first
    -  This reply was modified 1 year, 3 months ago by [qtwrk](https://wordpress.org/support/users/qtwrk/).

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘LSCWP Database’ is closed to new replies.

 * ![](https://ps.w.org/litespeed-cache/assets/icon-256x256.png?rev=2554181)
 * [LiteSpeed Cache](https://wordpress.org/plugins/litespeed-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/litespeed-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/litespeed-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/litespeed-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/litespeed-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/litespeed-cache/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [qtwrk](https://wordpress.org/support/users/qtwrk/)
 * Last activity: [1 year, 3 months ago](https://wordpress.org/support/topic/lscwp-database/#post-18343656)
 * Status: resolved