ideas icon indicating copy to clipboard operation
ideas copied to clipboard

Cull database

Open AaronHolbrook opened this issue 8 years ago • 4 comments

Many times in working with and developing a large site you need quite a few things set up (settings, options, etc) exactly how it is on production, however you don't necessarily need EVERY single record, post, post meta and media all cluttering up your local machine.

I think the ability to cull the database of everything except a handful of posts would be fantastic.

i.e.

wp db cull --post-type=posts --preserve=100

Or something to that effect.

AaronHolbrook avatar Jan 19 '17 15:01 AaronHolbrook

This would be an interesting problem to solve.

danielbachhuber avatar Jan 19 '17 21:01 danielbachhuber

I think the biggest challenge is to do this quickly/efficiently without having to comb through every single post/post-meta row.

I.e. something akin to mysql's truncate. BUT how do we do that AND still preserve SOME items?

Thinking out loud, what if we copied over the items we wished to preserve to a tmp table/in memory and then truncated the post/postmeta tables, then copied the preserved items back?

I'm sure there would be issues, but again, just thinking outside the box.

AaronHolbrook avatar Jan 19 '17 21:01 AaronHolbrook

Needs clarification: are we looking for a tool to quickly drop everything except a group of chosen data, or a random group of data?

Dropping all but the 10 latest posts, or the 10 earliest posts, or any 10 random posts, is an easy database query. Doing it for 10 specific posts would require identifying the posts, and by then, the work is done; automation provides little after that point.

joeldcanfield avatar Nov 20 '22 19:11 joeldcanfield

Marked this as state:considering. I think it's an interesting idea but there are a fair number of conceptual questions to work through (e.g. "what gets deleted?")

danielbachhuber avatar Apr 26 '23 18:04 danielbachhuber