Bug #10303 Misleading Last_query_cost value
Submitted: 1 May 2005 23:34 Modified: 27 Oct 2005 7:01
Reporter: Jacek Becla Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.4-beta-standard OS:Linux (Redhat Enterprise Linux)
Assigned to: Ramil Kalimullin CPU Architecture:Any

[1 May 2005 23:34] Jacek Becla
Description:
Last_query_cost is not always updated, therefore it is not obvious if the reported value is for the last query or one of the previous ones.

How to repeat:
Use two queries that have different costs, run query 1, then query 2, then again query 1. If query 1 has cost c1, and query cost c2, then you will see the cost c1 after you run query 2 the second time.

Suggested fix:
I guess the query cache is used when query 2 is executed second time, that is why the Last_query_cost is not updated. It would be useful to set it to 0 in such case.
[1 May 2005 23:39] Jacek Becla
Correction to "how to repeat": If query 1 has cost c1, and query cost c2, then you will see the cost _c2_ after you run _query 1_ the second time.
[2 May 2005 14:14] Hartmut Holzgraefe
verified, "SHOW STATUS LIKE 'last_query_cost'" is not reset for queries served from query_cache
[18 May 2005 8:05] Michael Widenius
Patch is in principle ok, but we should also make last_query_cost_value thread specific to make it more useful when there is many users in the system
[1 Sep 2005 10:08] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/29161
[5 Sep 2005 22:31] Michael Widenius
Still more work to do. See mail for details
[6 Sep 2005 10:02] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/29355
[25 Oct 2005 8:56] Ramil Kalimullin
fixed in 5.0.16
[27 Oct 2005 7:01] Jon Stephens
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

Documented in 5.0.16 changelog & Manual server variables section. Closed.