I have MySql table with a huge ammount of rows. I m doing the simple request and it works pretty fast. The only one problem fetching the data to client is terribly slow for about 150 secs when the request itself takes only 0.3 sec.
I am using php 5.3 + ZendFramework on client and Amazon EC2 MySql instance. PHP code and MySql are located on the different servers.
Can anyone tell me how to increase the data fetching speed?
Based on the comments you eventually provided the query that you are running.
select * from table
You also said that you have "a huge ammount of rows". This should be simple enough for you to understand why it takes forever to transfer to the box querying your database.
And also, just because your query runs fast, you still have to deal with network limitations. Plus, once you actually receive the result, hypothetically, if you were using an ORM for instance, you could find that hydration of the result set adds complexity and time to your request.
Overall, you answered this question yourself. Don't do a
select * from table
where the table is "enormous".You should look at adding limits and offsets to your query and only select the rows that you actually need.
Also, "huge" is extremely subjective. To me, a large table is about 10million rows. But to someone else 10million is pretty small. I wouldn't even like to put a number on what a huge table might be.