Closed aidvu closed 3 years ago
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.
meta_value
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.
Review with hide whitespace changes. :)
hide whitespace changes
Thanks for the PR, @aidvu !
Glad I could help.
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.