_cornerstone_data duplicates (_postmeta table)

Hello Themeco,
We have a lot of duplicates in the _postmeta table using the _cornerstone_data meta_key.

They could be caused by an older version of the theme/plugin (we’ve been using Pro since it was created from Theme X + Cornerstone).

How do you suggest we clean it and make sure we delete the unused duplicates? (I guess deleting them all but one could work)

Any suggestion/query would be appreciated! :slight_smile:

Hi @magikweb,

Thanks for reaching out.

The _cornerstone_data meta key stores the page settings and the attribute values into it, and the same meta key stored revision data or updated data for the same post.
I would suggest you not delete any of those, as we can’t be sure about which will be needed in the future. Still, if you want to delete it, please take a backup of your Database and delete the data or record based on the latest meta_id.
In your screenshot, that might be the 19856 for the post 4247. Please find a few of the free database backup plugin in the WordPress repository.

  1. https://wordpress.org/plugins/wp-database-backup/
  2. https://wordpress.org/plugins/wp-dbmanager/

Hope it helps.
Thank

Thank you @tristup,
We scanned all values and they seem to be exactly the same, but your point is interesting.

How can we tell if it’s bound to a revision? Can we find that out using a different table?
(we are developers, you can go technical if you know)

In the meantime, we’ll look into autocleaning old revisions.

That would be a very useful information!

Hi @magikweb,

Most of the cases, it stores a single record for the _cornerstone_data meta key, but as it shows the multiple records for a single post, there might be the revision which causes that. The revision may be due to the version of the theme or else.
If you still want to point out the latest or existing one, I would request to update the first section of post 4247 and check which row has changed with the value. It helps you to recognize the current record row.

I tried in my local setup bt changing the Font Weight and found that the changed value in the database. Please find the screenshot describing it.

Thanks

1 Like

I went ahead and updated the section_base_font_size of a post that has the _cornerstone_data 328 times.
It updated every single one of them to the same value, so I’m pretty confident these duplicates can be removed safely.

I will be making a snippet to loop in all 100+ sites that use Pro on our Multisite installation to clean it up. I can’t confirm what caused this or if it’s because we use WPMU, but it’s consuming a lot of space (and the disk is freaking out when we save).

Hopefully it’s from an older version of Pro (this WPMU has been using Theme X for a long time way before Pro existed)! :slight_smile:

Hey @magikweb,

Before running your snippet in all sites I’d recommend you to back up your databases in case if anything goes wrong. Hopefully that should resolve the problem.

Let us know how it goes!

So far so good, everything seems stable and lighter.
If someone wants to see their duplicates (and evaluate the risk), here’s a safe query to find them (The {$site_id} is the blog_id).

SELECT `meta_id`, `post_id`, `meta_key`, COUNT(*) AS count FROM `wp_{$site_id}_postmeta`
GROUP BY `post_id`, `meta_key`
HAVING count > 1
ORDER BY `meta_id` DESC;

Hi @magikweb,

Thank you for sharing your mySQL query code and we are great that it went smoothly on your multisite installation. On the other hand, if you have any other concerns, feel free to reach us.

Thank you.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.