On Thu, Oct 27, 2011 at 09:17:21PM -0500, tamouse mailing lists wrote: > > That said, I think there must be a way to do this in SQL. Absolutely, there's a way to do this in SQL; "select contract, sum(1) from test_table group by contract" But as I said, simply counting is not the intent of the actual processing that will be done. I need to find a method that can iterate through a large number of records and process each record (in whatever way I choose to define) without running out of RAM. I only need to access one record at a time, so I thought this would be pretty trivial, and was surprised to find that the routine ran out of memory. This simple counting exercise is merely a test of the loop algorithm so that I can do a 'cmp' or 'diff' comparison of the output of the PHP versus the output of the SQL to verify that in fact the PHP algorithm is indeed finding and processing each record (and thus arriving at the same per-contract counts that the SQL statement does). I will experiment with your suggestions. Thank you, Jim -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php