Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Quick links: [Using](#using) | [Installing](#installing) | [Contributing](#contr
## Using

~~~
wp search-replace <old> <new> [<table>...] [--dry-run] [--network] [--all-tables-with-prefix] [--all-tables] [--export[=<file>]] [--export_insert_size=<rows>] [--skip-tables=<tables>] [--skip-columns=<columns>] [--include-columns=<columns>] [--precise] [--recurse-objects] [--verbose] [--regex] [--regex-flags=<regex-flags>] [--regex-delimiter=<regex-delimiter>] [--regex-limit=<regex-limit>] [--format=<format>] [--report] [--report-changed-only] [--log[=<file>]] [--before_context=<num>] [--after_context=<num>]
wp search-replace <old> <new> [<table>...] [--dry-run] [--network] [--all-tables-with-prefix] [--all-tables] [--export[=<file>]] [--export_insert_size=<rows>] [--skip-tables=<tables>] [--skip-columns=<columns>] [--include-columns=<columns>] [--smart-url] [--analyze-tables] [--precise] [--recurse-objects] [--verbose] [--regex] [--regex-flags=<regex-flags>] [--regex-delimiter=<regex-delimiter>] [--regex-limit=<regex-limit>] [--format=<format>] [--report] [--report-changed-only] [--log[=<file>]] [--before_context=<num>] [--after_context=<num>]
~~~

Searches through all rows in a selection of tables and replaces
Expand Down Expand Up @@ -73,6 +73,23 @@ change primary key values.
Perform the replacement on specific columns. Use commas to
specify multiple columns.

[--smart-url]
Enable smart URL mode. Automatically skips dozens of WordPress core columns
that cannot contain URLs (like post_type, post_status, user_pass, etc.),
significantly improving performance for URL replacements. This is
particularly useful when migrating sites or changing domain names.
Performance: ~34% faster on large databases.
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description shows test results indicating 41.6% performance improvement, but the README states ~34%. While both might be valid depending on the database, it would be better to use consistent numbers or provide a range (e.g., '30-40% faster' or '~34-42% faster') to set accurate expectations.

Suggested change
Performance: ~34% faster on large databases.
Performance: ~34–42% faster on large databases (depending on the database).

Copilot uses AI. Check for mistakes.
Note: This flag is automatically enabled when the search string starts
with http:// or https://. Use --verbose to see which columns are skipped.

[--analyze-tables]
Enable advanced table analysis mode. Analyzes MySQL column datatypes
to automatically skip non-text columns (integers, dates, enums, etc.)
and columns matching common WordPress-style naming patterns (e.g. `*_id`,
`*_count`, `*_status`, etc.) in addition to the static skip list. Useful
for plugin tables with custom schemas. Requires --smart-url to be enabled.
Note: Adds a small overhead for table introspection.

[--precise]
Force the use of PHP (instead of SQL) which is more thorough,
but slower.
Expand Down Expand Up @@ -139,6 +156,12 @@ change primary key values.
# Search/replace to a SQL file without transforming the database
$ wp search-replace foo bar --export=database.sql

# URL replacement with smart column skipping (faster for URL changes)
$ wp search-replace 'http://example.test' 'http://example.com' --smart-url

# URL replacement with advanced table analysis for plugin tables
$ wp search-replace 'http://old.test' 'http://new.test' --smart-url --analyze-tables

# Bash script: Search/replace production to development url (multisite compatible)
#!/bin/bash
if $(wp --url=http://example.com core is-installed --network); then
Expand Down
Loading