Tag: Database

  • The “Install & Delete” Rule: The AgilePress Guide to Disposable Plugins

    WordPress users suffer from digital hoarding.

    You look at a typical dashboard today, and you will see 45 active plugins. Among them is a tool used to migrate the site three years ago, a thumbnail regenerator used during a theme redesign in 2024, and a database cleaner that runs a heavy cron job every day for no reason.

    At AgilePress, we treat plugins like scaffolding on a building. You put the scaffolding up to fix the roof or paint the walls. When the job is done, you take the scaffolding down. You do not leave it attached to the building forever.

    Leaving utility plugins installed introduces three massive risks:

    1. Security: An inactive or forgotten plugin is the #1 vector for malware injections.
    2. Database Bloat: Many plugins inject their menus and settings into the wp_options table even when deactivated.
    3. Overhead: Background tasks (cron jobs) from forgotten utility plugins consume server CPU.

    Here is the definitive AgilePress list of Disposable Plugins: tools you should install, use for their specific mission, and immediately delete.


    Mission 1: Database Surgery & URL Routing

    These are heavy-duty tools that rewrite your core data. They are incredibly powerful, but leaving them installed is a major security vulnerability.

    • Better Search Replace: The industry standard for migrating from HTTP to HTTPS or changing a domain name. Run your search, replace the strings, and delete it immediately.
    • AAA Option Optimizer: As discussed in our database guide, this is the best visual tool to find heavy, autoloaded rows in your wp_options table. Identify the culprits, toggle them off, and delete the plugin.
    • Advanced Database Cleaner: Use the PRO version to scan for orphaned tables and cron jobs left by old plugins. Purge the garbage, then remove the cleaner.
    • WP Bulk Delete: If you inherit a site with 50,000 spam comments or thousands of useless Custom Post Types, doing it via the standard WordPress UI will crash your browser. Use this to drop them in bulk, then delete.
    • WP-DBManager: An old-school but highly effective tool if you need to optimize, repair, or drop specific SQL tables directly from the dashboard. Once the surgery is successful, scrub up and delete it.

    Mission 2: Diagnostics & Performance (The Inspectors)

    These tools are built to tell you what is wrong with your site. Because they log every single process, they inherently slow down your site while active.

    • Query Monitor: The holy grail for developers. It tells you exactly which plugin or SQL query is slowing down your page. Warning: It will slow down your admin area drastically while active. Turn it on, take your notes, and delete it.
    • Code Profiler: Measures performance at the PHP level. If your site is slow but Query Monitor doesn’t show slow database queries, Code Profiler will tell you which specific PHP script is eating your CPU. Run the report, then delete it.
    • WP Crontrol: Essential for finding stuck scheduled tasks (cron jobs). If a backup plugin failed to run, the cron might be stuck in a loop. Delete the orphaned cron events, then delete WP Crontrol.
    • WS Action Scheduler Cleaner: WooCommerce relies on the “Action Scheduler” to process webhooks and subscriptions. Sometimes, this table bloats to millions of rows of “failed” or “complete” actions. Install this, flush the logs, and remove it.
    • Fatal Error Notify: We prefer server-level debug.log files, but if you are doing a major WooCommerce upgrade and want instant email alerts if a fatal PHP error occurs during the transition, install this. Once the site is stable for 48 hours, remove it.

    Mission 3: Media & Content Logistics

    Content migration plugins usually feature heavy UIs and background processors. They have no place on a live, functioning production environment.

    • Regenerate Thumbnails: You changed your theme, and now all your grid images look skewed. Install this, let it resize your entire media library to the new CSS dimensions, and delete it. It serves zero purpose once the images are cut.
    • Export Media Library: Sometimes you just need to extract a clean .zip of all your images without touching the database. Export them, then delete the plugin.
    • WP All Import / WP All Export (or any CSV importer): You used this to import 500 WooCommerce products from a supplier. The import is done. Do not leave this massive plugin sitting in your dashboard.
    • Convert to Blocks: If you are migrating a 10-year-old blog from the Classic Editor to the Block Editor (Gutenberg), this plugin will bulk-convert your old HTML posts into native blocks. Once the conversion is complete, the plugin is useless. Delete it.

    Mission 4: Development & FSE Transitions

    These tools are used to bridge the gap between staging and production, or to configure modern Block Themes.

    • Create Block Theme: The official WordPress tool for configuring Full Site Editing (FSE) themes. As outlined in our FSE guide, use this to clone your theme, embed your local fonts, and save the .zip. Once your theme is generated and active, delete the plugin.
    • Theme Switcha: Allows administrators to preview and build a new theme behind the scenes while front-end visitors still see the old theme. Once you hit “Publish” on the new design, this plugin’s lifecycle is over.
    • WP Reset: Used strictly in development/staging environments. If you are testing 5 different membership plugins and want to wipe the database clean between tests, this is your tool. Never install this on a production site.

    Mission 5: Security Scanners

    At AgilePress, we believe security should happen at the server level (Nginx firewalls, Cloudflare, fail2ban), not via PHP.

    • NinjaScanner: A fantastic, lightweight malware and virus scanner. If you suspect a client’s site has been compromised, install this, run a deep file comparison against the WordPress repository, clean the injected PHP files, and then delete the scanner.
    • Wordfence Security (Scanner Only): Wordfence is a great tool, but leaving its Web Application Firewall (WAF) running via PHP adds overhead to every single visitor request. If you must use it, install it, run a deep scan to find vulnerabilities, fix them, and then delete it. Rely on your hosting provider for daily firewall protection.

    Conclusion: The AgilePress Protocol

    Look at your WordPress dashboard right now. Ask yourself this question for every single active plugin:

    “Does this plugin actively serve my front-end visitors or assist in my daily publishing routine?”

    If the answer is no, it is scaffolding. If it’s a tool you only need once a month, delete it and reinstall it next month. The 30 seconds it takes to reinstall a plugin is a small price to pay for a faster, safer, and cleaner database.

    Next Step: Log into your WordPress admin, go to your Plugins page, and delete at least three plugins you haven’t used in the last 30 days. Your server will thank you.

  • The Ultimate Guide to WordPress Database Optimization (Zero Technical Debt)

    There is a dangerous myth in the WordPress ecosystem: “If you install a good caching plugin, your site will fly.”

    This is a half-truth. Caching hides database problems from your logged-out visitors, but it doesn’t fix the engine. If your database is full of garbage from plugins you deleted in 2022, your admin dashboard will be sluggish, searches will crawl, and your TTFB (Time To First Byte) will tank the moment the cache expires.

    At AgilePress, we treat the database with absolute respect. It is not a junk drawer; it is the brain of your business. Here is the ultimate guide to keeping it clean, structured across three levels of technical difficulty.


    The best maintenance is the one you don’t have to perform. Out of the box, WordPress is configured to accumulate infinite bloat. Before we clean, we must turn off the faucet.

    Open your wp-config.php file and add these lines just above the “That’s all, stop editing!” line:

    1. Limit Post Revisions: By default, WordPress saves a copy of your post every single time you hit “Save.” A single post can easily spawn 150 useless database rows.PHPdefine( 'WP_POST_REVISIONS', 3 ); // Only keep the 3 most recent revisions
    2. Accelerate the Trash: By default, the WordPress trash empties every 30 days. Change it to 7.PHPdefine( 'EMPTY_TRASH_DAYS', 7 );
    3. Increase the Autosave Interval: Stop WP from hammering the database by saving drafts every 60 seconds.PHPdefine( 'AUTOSAVE_INTERVAL', 120 ); // Save every 2 minutes

    Phase 2: What Exactly Are We Cleaning?

    When we perform targeted maintenance, we attack four main sources of infection:

    1. Editorial Bloat: Old revisions, auto-drafts, and spam comments (wp_posts and wp_comments).
    2. Expired Transients: Temporary database caches (e.g., a Twitter feed API response) that are no longer valid (wp_options).
    3. Orphaned Metadata: Data assigned to a post or user that has already been deleted (wp_postmeta, wp_usermeta).
    4. Autoloaded Options (The Bottleneck): Complete configuration arrays from plugins you uninstalled months ago, which are still being loaded into your server’s RAM on every single page load.

    To clean this up, choose your weapon:


    Phase 3: The 3 Execution Paths

    Path 1: The Free Solution (The Smart Freeloader)

    Best for: Quick maintenance on low-budget sites.

    You don’t need to pay for basic hygiene, but you do need discipline.

    1. The Tool: WP-Optimize or WP-Sweep.
    2. The Process: Install the plugin. Go to the optimization section and check the boxes for “Clean all post revisions”, “Clean spam comments”, “Clean transients”, and “Clean orphaned postmeta”. Run the optimization.
    3. The AgilePress Rule: Uninstall the plugin when you are done. Do not leave WP-Optimize running in the background consuming resources to do a job that only needs to be done once a month.

    Path 2: The Premium Solution (The Agency Standard)

    Best for: Agencies inheriting bloated websites destroyed by previous developers.

    If you inherit a WooCommerce site that has cycled through 20 different plugins over 5 years, the free options won’t cut it. Free plugins cannot identify orphaned plugin tables or abandoned cron jobs.

    1. The Tool: Advanced Database Cleaner PRO (Approx. $39).
    2. Why it’s worth it: It is the only plugin that does “Reverse Engineering.” It scans your wp_options table and your scheduled tasks (Cron), and tells you exactly: “This data row belongs to the Elementor plugin, which is no longer installed.”
    3. The Process: It allows you to safely select and purge hundreds of Megabytes of orphaned garbage (entire tables and autoloads) without fear of breaking the site, because it categorizes exactly which plugin left the data behind.

    Path 3: The Ultra-Technical Route (The AgilePress Purist)

    Best for: Sysadmins and performance purists.

    Zero plugins. Total control. We use WP-CLI (the WordPress command-line interface) or direct SQL queries via phpMyAdmin/Adminer. (Warning: Always take a full database backup before doing this).

    Clean Revisions via SQL:

    SQL

    DELETE FROM wp_posts WHERE post_type = 'revision';
    

    Clean Orphaned Metadata (Postmeta with no associated Post):

    SQL

    DELETE pm FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL;
    

    Clear All Transients (Temporary Cache) via WP-CLI:

    Bash

    wp transient delete --all
    

    The Autoload Analysis via SQL: To find out if your database suffers from initial load “overweight” (the WordPress Site Health warning), run this to see which options are the heaviest:

    SQL

    SELECT option_name, length(option_value) AS option_value_length FROM wp_options WHERE autoload='yes' ORDER BY option_value_length DESC LIMIT 20;
    

    If you spot a massive option from a deleted plugin, execute it without mercy:

    Bash

    wp option delete name_of_the_garbage_option
    

    Conclusion: Maintenance is a Habit, Not a Plugin

    A well-maintained WordPress database should not weigh more than 30-50 MB for a standard corporate site, and the autoloaded data should never exceed 1 MB.

    If you apply Phase 1 (limiting revisions in wp-config), 80% of the problem solves itself. For the remaining 20%, audit your database every 3 months using the path that best fits your technical level.

    Flee from “Vendor Lock-in,” not just in your themes, but also in the data those themes and plugins leave behind when you finally fire them.