Bug #116652 It is recommended to add the updated_rows field in the slow log
Submitted: 14 Nov 2024 11:44 Modified: 15 Nov 2024 16:19
Reporter: karry zhang (OCA) Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Logging Severity:S3 (Non-critical)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any

[14 Nov 2024 11:44] karry zhang
Description:
Slow log has a field Rows_sent. For DML statements, this field has no meaning and returns 0. 

For slow SQL statements of the DML type, we want to obtain information about the actual number of updated rows.

How to repeat:
Enable slow log and execute some slow DML statements.

Suggested fix:
For DML, change the Rows_sent field, or just add a new field updated_rows.
[14 Nov 2024 13:26] MySQL Verification Team
Hi Mr. zhang,

Thank you for your bug report.

However, this is not a bug.

For DMLs that change data, you get rows_examined, because of DMLs only those that return rows have that column filled up correctly.

Here is. the example of one UPDATE and one SELECT:

| start_time                 | user_host                     | query_time      | lock_time       | rows_sent | rows_examined | db   | last_insert_id | insert_id | server_id | sql_text                                                                                                                                                                                                                                                                                                                                                                                 | thread_id |
| 2024-11-14 15:16:10.864263 | xxxaxxx] @xxxxx [] | 00:00:01.371920 | 00:00:00.000001 |         0 |       1474563 | test |              0 |         0 |     82721 | 0x7570646174652074322073657420783D226464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646422 |         9 |
| 2024-11-14 15:17:28.410593 | xxx[xxx] @xxxx [] | 00:00:13.860038 | 00:00:00.000001 |  24665398 |       1491400 | test |              0 |         0 |     82721 | 0x73656C656374202A2066726F6D2074312C207432 |
+----------------------------+-------------------------------+-----------------+-----------------+-----------+---------------+------+----------------+-----------+-----------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+

Do you see that value 24665398 ...... that is rows_sent for the SELECT query.

Not a bug.
[15 Nov 2024 2:02] karry zhang
I mean for dml, Rows_sent always returns 0. For example, you can execute a slow delete or update or insert statement.
[15 Nov 2024 10:50] MySQL Verification Team
Hi,

What you describe is intended behaviour.

Rows_Sent means rows that server is sending to the client side.
[15 Nov 2024 16:19] karry zhang
I noticed the introduction of this field in the documentation, and I think this bug report is more reasonable as a feature request.

For slow SQL, we want to get more information. This field is meaningless for DML, so I suggest changing it to the number of changed rows. Or, as I mentioned earlier, directly add a new field update_rows.
[15 Nov 2024 16:21] MySQL Verification Team
Hi,

Introducing changed_rows was our addition to the already verified feature request !!!!!

So this is done already !!!!!!