There is no single rebuild time for WordPress. If you mean WordPress's built-in database repair or optimization, a small site often finishes in seconds to a couple of minutes, while a bloated database can run for several minutes to half an hour. If you mean rebuilding a large table through phpMyAdmin, a migration, or a search-replace operation, expect minutes to hours depending on size, server power, and the method. The key condition is which "rebuild" you actually need: built-in repairs touch a limited set of core tables, while migrations, index rebuilds, and bulk cleanup scale with rows, indexes, and write activity.
The phrase gets used loosely, so the honest answer starts with a diagnosis. People say "rebuild the database" when they mean one of at least five different jobs, and each has a different clock. A WordPress core repair, a table optimization, a full dump-and-restore migration, an index rebuild on a large table, and a plugin-driven cleanup can differ by orders of magnitude on the same site. Estimating without knowing which one you're doing is how site owners end up planning a five-minute maintenance window for a two-hour job.
For planning purposes, use the driver rather than the label. Rebuild time is dominated by the number of rows and indexes being rewritten, the disk throughput of the database server, the amount of locking that forces serialized work, and whether the operation is CPU-bound (sorting, index construction) or I/O-bound (dumping, restoring, altering). A fast NVMe-backed database host can finish in a fraction of the time a shared spinning-disk host needs for the same row count. Your PHP timeout and max execution time matter for admin-triggered jobs, and they're a common reason a rebuild "fails" rather than finishes slowly.
The Five Jobs People Call a Database Rebuild
Core repair and optimization. WordPress ships with tools under Tools > Site Health and via WP-CLI (wp db repair, wp db optimize) that check and optimize core tables. Repair mostly scans and fixes MyISAM-style corruption or checks InnoDB tables; on modern WordPress installs most tables are InnoDB, where "repair" is largely a check. Optimization on InnoDB is often a no-op or a table rebuild depending on the storage engine and options. These are the fastest jobs, usually seconds to a few minutes.
Table optimization or engine conversion. Converting a large table from one storage engine or row format to another rewrites the table and its indexes. This is a genuine rebuild and scales with table size. A modest wp_postmeta table with a few hundred thousand rows might take seconds to a minute; a multi-million-row table can take many minutes and can lock writes during the operation.
Full migration by export and import. Dumping the database and restoring it elsewhere rebuilds every table and index. This is often what agencies mean by "rebuilding." Time depends heavily on dump size, import method (command line versus a web-based tool), and whether indexes are built during import or after.
Index rebuild. Rebuilding indexes on a large table (after a bulk delete, for example) is a CPU- and I/O-intensive operation that scales with rows and index width. This is the slowest per-byte category on big datasets.
Cleanup and reinstall of plugin data. Deleting orphaned options, transients, and postmeta, or reinstalling a plugin that recreates its tables, is a mixed operation: the delete can be slow, and the recreate is usually fast.
The confusion matters because the scariest-sounding version—"my whole database is rebuilding"—is usually the fastest, while the most routine-sounding "just optimize the tables" can be the slowest on a giant site.
Typical Time Ranges by Database Size
These are planning ranges for a healthy server, not guarantees. They assume a database host with reasonable disk throughput and no concurrent heavy traffic. Doubling the row count roughly doubles the time for rewrite operations; it does not scale linearly for every operation, because index builds and sorts have their own overhead.
| Database profile | Core repair/optimize | Table rewrite (engine/row format) | Full dump and restore | Index rebuild on largest table |
|---|---|---|---|---|
| Small blog, under 50 MB, under 50k rows | Seconds to under 2 minutes | Seconds to 1 minute | 1–5 minutes | Seconds |
| Mid-size site, 100–500 MB, 100k–500k rows | 1–5 minutes | 1–10 minutes | 5–30 minutes | 1–10 minutes |
| Large site, 1–5 GB, 1M–5M rows | 5–20 minutes | 10–60 minutes | 30 minutes to 3 hours | 10–60 minutes |
| Very large store or multisite, 10 GB+ | 20 minutes to hours | Hours | Several hours to a day | Hours |
Treat the first column as the "built-in WordPress" case and the third as the "I'm moving or restoring the database" case. The middle two columns are where most surprises live, because they're the jobs people start in a plugin or phpMyAdmin without realizing they're rewriting gigabytes.
A quick arithmetic check helps. If a 500 MB database restores in 10 minutes on your host, you're moving roughly 50 MB per minute, or under 1 MB per second. A 5 GB database at that same throughput takes about 100 minutes. That linear estimate is the most useful number in this article: measure your host's restore throughput once, then scale by size. It overestimates if indexes build faster in bulk and underestimates if the server is under load.
What Actually Drives the Clock
Row count and index count, not file size alone. Two databases of the same megabyte size can take very different times if one has many narrow rows and the other has few wide rows with many indexes. Index rebuilds are the multiplier; a table with eight indexes costs substantially more to rewrite than one with two.
Storage engine. InnoDB handles most of WordPress's tables and supports online-ish operations better than older MyISAM tables, but large InnoDB table rebuilds still require significant temporary space and can lock writes. MyISAM repair is often quick but fragile. On older installs you may find a mix, which complicates estimates.
Disk throughput and temporary space. A rebuild that needs to write a copy of the table and its indexes can temporarily double storage needs. On a host with limited disk, the operation can stall or fail rather than finish slowly. NVMe storage versus network-attached or shared storage can be the difference between minutes and an hour.
Server CPU and memory. Sorts and index builds are CPU-bound. A database with limited buffer pool memory will read from disk repeatedly, which can turn a fast job into a slow one. This is why the same database dump can restore in 8 minutes on a well-provisioned host and 45 minutes on a constrained shared plan.
Concurrency and locking. Any operation that locks tables blocks writes. On a live site, checkout, comments, and admin saves stall or fail. Some operations take longer precisely because they're waiting on locks held by other queries. The safest plan is to run rebuilds in a maintenance window with traffic paused.
PHP and execution limits. Admin-triggered jobs running through WordPress or a plugin are constrained by PHP's max execution time, memory limit, and web server timeouts. A job that would take 20 minutes may be killed at 30 or 60 seconds unless you raise limits or switch to WP-CLI or command-line MySQL. This is a frequent cause of "the rebuild keeps failing," which people misread as "it takes forever."
Network round trips in web-based tools. phpMyAdmin and similar browser tools can be much slower than command-line mysql for large imports, because each statement or chunk travels over HTTP. The same dump that imports in 10 minutes via the mysql client can take an hour through a browser.
Timing the Built-In WordPress Options
WordPress core's repair and optimization tools are modest. wp db repair checks and repairs core tables and generally completes quickly on healthy databases; on InnoDB, repair is mostly a validation step. wp db optimize runs OPTIMIZE TABLE, which on InnoDB may rebuild the table or do nothing depending on the MySQL version and settings. On a small site, both are usually under a minute. On a very large site, optimize can be the slow part, because it may rewrite large tables.
The built-in options don't rebuild plugin tables, don't reindex everything, and don't touch custom tables. If a plugin's settings page promises to "rebuild the database," read what it actually does: many such buttons delete transients, clear caches, or recreate one or two tables, which is quick; some run full table rewrites, which are not. The label is not the specification.
A practical habit: run wp db size --tables or query information_schema.TABLES before starting anything, so you know the largest tables and total size. That single step turns a vague worry into a defensible estimate. Note that wp db size returns approximate InnoDB row counts from table statistics; for a rebuild estimate, the byte size and index count matter more than the exact row count.
Migrations, Restores, and Search-Replace Operations
A migration rebuilds the database in the destination environment. The dump itself is usually fast to create; the restore is where time goes. Command-line mysql or wp db import is the fastest common path. On a mid-size 500 MB database, a restore on decent hardware in the 10–30 minute range is typical. On a 5 GB database, several hours is plausible, especially if indexes are built as data loads rather than after.
A search-replace on serialized data—the classic "change the site URL" step—scales with the size of the affected tables. It's often the slowest part of a migration on large sites. WP-CLI's wp search-replace is far faster than PHP-based plugin replacements for big datasets, but it still reads and rewrites every affected row. A multi-gigabyte wp_posts and wp_postmeta combination can take tens of minutes to over an hour. Run --dry-run first to see what will change; that itself takes time, which is a useful preview of the real run.
For multisite networks, the database is often much larger than the sum of individual sites suggests, with shared tables and per-site tables. A network-wide rebuild can be hours, especially if search-replace runs across all sites. Estimate from the total network size, not from one site's dashboard numbers.
Why Rebuilds Fail or Stall—and What It Means for Time
Timeout cuts. The job was progressing but hit max execution time. The fix is command-line execution or raised limits; the time doesn't disappear. Lock waits. Other queries held locks, and the rebuild waited. The clock includes waiting, not just working. Disk space exhaustion. The rebuild needed a temporary copy and ran out of space. It stops, often leaving partial state. Corruption discovered mid-run. A repair can stop when it finds a corrupt page; the outcome is a failed repair with an error, not a time. Server restarts. Long operations interrupted by host maintenance or a process kill may roll back. On InnoDB, a large transaction rollback can itself take time.
For planning, the useful distinction is "how long if nothing goes wrong" versus "how long including retries and recovery." A 30-minute rebuild that fails three times costs 90 minutes plus cleanup. Build buffer into the maintenance window.
How to Estimate Your Own Rebuild
Start with the largest tables in bytes and the total database size. Measure your host's throughput with a controlled restore of a representative table or a dump of known size, not a full test on production. If a 200 MB dump restores in 4 minutes, you're around 50 MB per minute; a 2 GB target is roughly 40 minutes before overhead. Then adjust for index count, concurrency, and whether the method is browser-based. If the job is an index rebuild rather than a restore, measure a smaller table's rebuild and scale by rows and index count.
Don't run the measurement during peak traffic, and don't treat a first successful run as a guarantee for the next one—cache state, concurrent load, and storage contention can shift times substantially. For the scariest scenario, a 10 GB database, plan on hours and a full maintenance window, and verify you have a tested backup and enough temporary disk space before starting.
The practical summary: WordPress's built-in repair and optimize are typically seconds to minutes; a full restore is minutes to hours by size and host; table rewrites and index rebuilds are the slow, capacity-sensitive jobs. Measure one throughput figure on your own host, scale it by database size, and add buffer for locking and failure recovery. That turns "how long does it take" from a guess into a number you can defend.