Skip to content

Chunk query that can potentially OOM - #153

Merged
schlessera merged 2 commits into
wp-cli:masterfrom
aidvu:update/chunk-php-handle-col
Jan 14, 2021
Merged

schlessera merged 2 commits into
wp-cli:masterfrom
aidvu:update/chunk-php-handle-col

Conversation

@aidvu

@aidvu aidvu commented Dec 24, 2020

Copy link
Copy Markdown
Contributor

Unbound query has potential to return millions of
rows, and it's fairly easy to run into memory problems.

e.g. we had a problem with a ~4GB DB that was returning
13 million rows to check for the meta_value column.

The fix loops through the table fetching 1000 at a time.
Added ORDER BY statement, so we can safely iterate through
the primary keys.

Using ASC ordering, so the new items come last,
in case something gets added while it's running.

Unbound query has potential to return millions of
rows, and it's fairly easy to run into memory problems.

e.g. we had a problem with a ~4GB DB that was returning
13 million rows to check for the `meta_value` column.

The fix loops through the table fetching 1000 at a time.
Added ORDER BY statement, so we can safely iterate through
the primary keys.

Using ASC ordering, so the new items come last,
in case something gets added while it's running.
@aidvu
aidvu requested a review from a team as a code owner December 24, 2020 16:58
@aidvu

aidvu commented Dec 24, 2020

Copy link
Copy Markdown
Contributor Author

Review with hide whitespace changes. :)

Fix variable reuse for $wpdb->update()
@aidvu
aidvu force-pushed the update/chunk-php-handle-col branch from 23fe462 to bba9be5 Compare December 25, 2020 16:13
@schlessera schlessera added bug command:search-replace Related to 'search-replace' command labels Jan 14, 2021
@schlessera schlessera added this to the 2.0.10 milestone Jan 14, 2021
@schlessera
schlessera merged commit cd03d7e into wp-cli:master Jan 14, 2021
@schlessera

Copy link
Copy Markdown
Member

Thanks for the PR, @aidvu !

@aidvu

aidvu commented Jan 15, 2021

Copy link
Copy Markdown
Contributor Author

Glad I could help.

@aidvu
aidvu deleted the update/chunk-php-handle-col branch January 15, 2021 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug command:search-replace Related to 'search-replace' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants