large wp_options table in prod, but small in dev
-
i’m trying to solve the issue where the wp_options table is very large. my plan was to take a backup of the database, and restore it to my dev environment so i could test pruning it down. however, when i restore, i can’t get the same size results on disk in my dev environment that are in prod. i used the site health page in the tools section to see the overall size of the database, and then ran a database query to find out what were my largest tables.
i’ve tried exporting and restoring the database (using mysql workbench data export / restore) to my development environment so that i can test pruning the wp_options table, however, when i’ve restored an export of the database the wp_options table restores much smaller in dev than in prod- actually all of the tables restore much smaller. tables will have the same number of total rows, but the size is vastly different- like 4GB in prod to 10MB in dev.
i also tried restoring my dev environment via the all-in-one wp migration tool, but the result is the same. how do i get the same database size on disk across my environments? or how do i shrink the database size on disk in prod?
the query i’ve used for getting row size is below.
SELECT table_schema as <code>Database</code>, table_name AS <code>Table</code>, round(((data_length + index_length) / 1024 / 1024), 2) <code>Size in MB</code> FROM information_schema.TABLES ORDER BY (data_length + index_length) DESC;
-
after more research i think this is related to the difference between a logical backup and physical backup in mysql. seems like i’d need to schedule some maintenance and make a copy of the database and put that into my dev environment.
does anyone know if i could just take a logical backup of prod, and restore it immediately to prod to get the disk space back? is that a bad idea?
1. backup first.
2. does the database export missing any data that you notice? if not, isn’t it a good news? restore and replace the prod database with the database export to get smaller database size too. (backup first!)i went ahead and did a logical backup and restore of just the wp_options table with the mysql workbench, and the table size went down to just a few MB from 4GB. The problem entries are still in wp_options, and need to be cleaned out, but the immediate storage relief is nice.
i think this can be closed.
The topic ‘large wp_options table in prod, but small in dev’ is closed to new replies.