Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
I have a very large table that I need to iterate through with a PHP script and I can't do all of the results at once so I do it in sections with a LIMIT like for ($x = 0; $x < 10000000; $x += 1...
#1: Initial revision
Iterating through a MySQL table with a LIMIT clause and PHP gets progressively slower
I have a very large table that I need to iterate through with a PHP script and I can't do all of the results at once so I do it in sections with a LIMIT like ``` for ($x = 0; $x < 10000000; $x += 10000) { $sql =" SELECT * FROM example_table ".$x.",10000 ORDER BY primary_key_column"; $results = $connection->results($sql); //Do stuff with results } ``` At first the select returns the data very quickly but as time goes on they take more and more time until it plateaus at around 12x15 times longer than the first select. Would there be a way to do this where the subsequent loops don't take so much longer?