Returning the first N results

You don't want all million rows returned at once, you want a page at a time.

Solution

Use the LIMIT keyword to modify your SELECT ref.

Discussion

If you want to limit your results to a manageable size, use the LIMIT keyword in your query. So to get the first five results:

SELECT * FROM companies ORDER BY co_id LIMIT 5;
   

Note you should always have an ORDER BY clause, otherwise you won't know which five results you are getting.