If we want to do processing on ALL the rows in a table (of a few
milions rows), if using language such as php, we need to limit the
amount of rows each time and process them chunk by chunk to prevent
memory overflow.

If using Stored Procedure, can this problem solved since data is always
at the server side? No need to divide the data into smaller chunks, and
let say, SELECT * FROM `table1` and loop all the rows using SP

Thanks for any comment.