user3239711 user3239711 - 3 months ago 23
MySQL Question

MySQL fetch time too important

My query as a small duration time when the Fetch time is quite large. What is exactly the fetching time. Can it be reduced ? Is it dependent on the network since the server is a remote one.

my Query is a simple one

SELECT * FROM Table WHERE id = a primary_Key;

Usually, the query returns between 5 and 50k rows.
But the table has 9 million Rows. The count(*) takes 82 seconds (duration) and 0 for fetching time.

Answer

Fetch time does depend on network speed. Your SELECT Count(*) ... query only returns a single number so network overhead is minimal.

To improve the speed, I suggest you only fetch the columns and rows you need (i.e. replace SELECT * ... with the exact columns you need).

Also, enabling compression between client and server will reduce time (but will slightly increase CPU usage for compressing/decompressing). See this related question.

Comments