9

Show status like 'Qcache_queries_in_cache' returns:

+-------------------------+----------+
| Variable_name           | Value    |
+-------------------------+----------+
| Qcache_queries_in_cache | 327      |
+-------------------------+----------+

How do I print these 327 queries?

In an attempt to optimize mysql caching I want to trying switching to "on demand" caching. But before I do I want to get a definitive sense of which queries are being cached or discarded. I tried mysql docs, google, and stackoverflow search but no luck.

2 Answers 2

8

AFAIK sql queries are not stored into Qcache only their hash. So there is no way to find what queries are now cached exept you execute one of your query and see the changes of Value column.

2
  • thx...I'm on a production server and executing the many queries performed and spotting changes isn't going to work. I was hoping for a debug mode of some sort.
    – user508627
    Commented Nov 16, 2010 at 0:06
  • Is there a way to get to those hashes?
    – simbabque
    Commented Apr 8, 2014 at 8:52
2

If You enable a Session Specific variable profiling

SET SESSION PROFILING=on;
show profiles;

Now by checking show profile for query your query_id;

mysql> show profile for query 2;

+--------------------------------+----------+
| Status                         | Duration |
+--------------------------------+----------+
| starting                       | 0.000017 |
| checking query cache for query | 0.000005 |
| checking privileges on cached  | 0.000003 |
| sending cached result to clien | 0.000005 |
| logging slow query             | 0.000002 |
| cleaning up                    | 0.000001 |
+--------------------------------+----------+

By checking the status column you can see whether the queries cached.

But this is only a session specific you have enable profiling for each session.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.