andersonbd1
andersonbd1

Reputation: 5386

mysql profiler "Sending data"

Is there an explanation of these statuses anywhere?

http://dev.mysql.com/tech-resources/articles/using-new-query-profiler.html

my specific question is in regards to this query:

select count(*)
from 135_5m.record_updates u, 135_5m.records r
where  r.record_id = u.record_id  and 
  (u.date_updated > null or null is null)  and 
  u.date_updated <= '2011-01-03';

which returns a single number - 4053904. So why would the majority of the time be spent in "Sending data"? Is it just poorly named? Surely "Sending data" must be doing more than just sending data?

+--------------------------------+-----------+-------+
| Status                         | Duration  | Swaps |
+--------------------------------+-----------+-------+
| starting                       |  0.000224 |     0 |
| checking query cache for query |  0.000188 |     0 |
| checking permissions           |  0.000012 |     0 |
| checking permissions           |  0.000017 |     0 |
| Opening tables                 |  0.000036 |     0 |
| System lock                    |  0.000015 |     0 |
| Table lock                     |  0.000067 |     0 |
| init                           |  0.000105 |     0 |
| optimizing                     |  0.000052 |     0 |
| statistics                     |  0.000254 |     0 |
| preparing                      |  0.000061 |     0 |
| executing                      |  0.000017 |     0 |
| Sending data                   | 32.079549 |     0 |
| end                            |  0.000036 |     0 |
| query end                      |  0.000012 |     0 |
| freeing items                  |  0.000089 |     0 |
| storing result in query cache  |  0.000022 |     0 |
| logging slow query             |  0.000008 |     0 |
| logging slow query             |  0.000008 |     0 |
| cleaning up                    |  0.000011 |     0 |
+--------------------------------+-----------+-------+

Upvotes: 7

Views: 6173

Answers (2)

hellojinjie
hellojinjie

Reputation: 2138

before sending data to client, mysql need to read data, the phase of read data may take the majrity time of "sending data"

Upvotes: 0

Mikko Wilkman
Mikko Wilkman

Reputation: 1535

http://dev.mysql.com/doc/refman/5.0/en/general-thread-states.html

Executing means the thread has started execution, Sending data apparently covers both the processing of the rows and sending the count back to the client.

Upvotes: 10

Related Questions