Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smarter replacement checks for columns #194

Open
1 task done
MarkBerube opened this issue Feb 15, 2024 · 1 comment
Open
1 task done

Smarter replacement checks for columns #194

MarkBerube opened this issue Feb 15, 2024 · 1 comment

Comments

@MarkBerube
Copy link
Contributor

MarkBerube commented Feb 15, 2024

Feature Request

Describe your use case and the problem you are facing
I have been actively trying to increase the velocity on my own URL S&Rs. To benchmark/diagnose how I could make them faster I started watching the SQL connections on large, test DBs with about 20gb worth of database rows living in wp_posts.

What I tended to notice are queries like the following:

UPDATE `wp_posts` SET `post_status` = REPLACE(`post_status`, 'http://dontmatter.co/', 'http://dontmatter.test/')

basically S&R is trying to replace on a column we can say confidently is not going to hold something I'd like to replace. One way around this is skipping these checks is to skip on this particular column. In my benchmarks case I skipped the following:

docker-compose run --rm wpcli wp search-replace --url=http://dontmatter.co/ 'http://dontmatter.co/' 'http://dontmatter.test/' wp_posts --recurse-objects --skip-columns=post_title,post_excerpt,post_status,comment_status,post_password,post_name,to_ping,pinged,guid,post_type,post_mime_type

a command that used to take me 32 minutes to execute now takes me 7 minutes with these changes.

Describe the solution you'd like

While I could do this for every single table in WP on my own, I feel this could be easier by being smarter about what columns we could skip automatically. Like we're never going to see something we'd like to replace on columns that act as binaries or columns that are like enums such as post_type that are all typed as varchar in the db.

@danielbachhuber
Copy link
Member

Thanks for the suggestion, @MarkBerube !

I'm open to a PR with improvements, as long as it's backwards compatible.

Alternatively, introducing a dedicated search-replace command for URLs might be a more productive path forward: #186

I don't have a strong opinion of one vs. the other at this time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants