3

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.

Indra Yadav
  • 600
  • 5
  • 22
user3239711
  • 639
  • 1
  • 7
  • 24
  • one is how long it takes to get the requested data from the database itself, and the other is how long before that gets sent to the client. – Randy Feb 03 '14 at 14:07
  • 1
    If you query by a primary key, you should only get 1 record (or none), not between 5 and 50k rows... – Tasos P. Feb 03 '14 at 14:08
  • You are right, there's an index on the column. My mistakes. but the question remains the same :-) – user3239711 Feb 03 '14 at 14:38

2 Answers2

2

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.

Community
  • 1
  • 1
Tasos P.
  • 3,994
  • 2
  • 21
  • 41
-3

Have you looked into using Mysql Indexes

bart2puck
  • 2,432
  • 3
  • 27
  • 53