title: MySql - slow sending data phase
body: <p>One of my queries on MySQL 5.0.45 is running slow in &quot;sending data&quot; phase. The query is a simple select, returns about 300 integer ID fields as result set.</p>
  <pre>
  mysql> SELECT source_id FROM directions WHERE (destination_id = 10);
  +-----------+
  | source_id |
  +-----------+
  |         2 |
  |         8 |
  ...
  |      2563 |
  +-----------+
  341 rows in set (2.13 sec)
  </pre>
  <p>I am note sure why is &quot;sending data&quot; phase so slow and what can be done to make it fast. Please note I am executing this query on MySQL prompt on the server itself, so not really expecting it to spend so much time in &quot;sending data&quot;. Any clues?</p>
  <p>If it helps, I have 3 text fields on this table, but since they are not being selected, I am expecting they are not cause of this slowness.</p>
  <p>This query runs thousands of times a day and can't really afford to spend 2 secs on it each time.</p>
  <p>Profiling result:</p>
  <pre>
  mysql> show profile for query 4;
  +--------------------------------+----------+
  | Status                         | Duration |
  +--------------------------------+----------+
  | (initialization)               | 0.000003 |
  | checking query cache for query | 0.000051 |
  | checking permissions           | 0.000007 |
  | Opening tables                 | 0.000011 |
  | System lock                    | 0.000005 |
  | Table lock                     | 0.000023 |
  | init                           | 0.00002  |
  | optimizing                     | 0.00001  |
  | statistics                     | 0.00006  |
  | preparing                      | 0.000014 |
  | executing                      | 0.000005 |
  | Sending data                   | 2.127019 |
  | end                            | 0.000015 |
  | query end                      | 0.000004 |
  | storing result in query cache  | 0.000039 |
  | freeing items                  | 0.000011 |
  | closing tables                 | 0.000007 |
  | logging slow query             | 0.000047 |
  +--------------------------------+----------+
  18 rows in set (0.00 sec)
  </pre>
  <p>UPDATE: I stumbled upon the following URL which says</p>
  <blockquote>
  <p>Each time means the time elapsed between the previous event and the new event. So, the line:<br />
  | Sending data | 0.00016800 |<br />
  means that 0.00016800 seconds elapsed between &quot;executing&quot; and &quot;Sending data&quot;. It is, it takes 0.00016800 seconds to execute the query.
  </p>
  </blockquote>
  <p><a href="http://forums.mysql.com/read.php?24,241461,242012#msg-242012" rel="noreferrer">http://forums.mysql.com/read.php?24,241461,242012#msg-242012</a></p>
  <p>Can somebody validate?</p>