in reply to More on selecting rows with DBI...
Just selecting the first n rows of a query is really a meaningless concept to a relational database. If you have to process 50,000 records the best way is use a cursor, so you access them a row at a time. Use $db_handle->prepare
and $db_handle->fetchrow_arrayref to loop through the dataset. See perldoc DBI.pm