Solved

Mysql not caching queries

Posted on 2016-10-13
4
46 Views
Last Modified: 2016-10-14
HI,
Following are some screen shots of mysql server running on my computer locally....
Following are the queries i ran  :
SHOW VARIABLES LIKE '%query_cache%';
SHOW STATUS LIKE '%qcache%';

select * from notes where id = '0002c1ff-d8a1-4cee-a499-448332c914de';

Open in new window

I have attached the result of above queries before and after the select * query execution....
The only change i see in qcache is  : Qcache_not_cached was 1 before select execution and after that it is 2.
Which signifies that the select query was not cached...
What could be the reason that this query was not cached...

How can i make the caching available ?

Thanks
qcache-after-select-execution.png
select-query.png
qcache-before-select-execution.png
query-cache-before-select-execution.png
0
Comment
Question by:Rohit Bajaj
4 Comments
 
LVL 29

Expert Comment

by:fibo
ID: 41843141
What happens if instead of count(*) you use the primary index (eg, prim_id) with count(prim_id)?
And instead of SELECT * use the field names?

Finally, your "query" is really "2 queries" and this might impact the value you see after the second query. What is the cache after the 1st query?
0
 

Author Comment

by:Rohit Bajaj
ID: 41843170
HI,
The select count(*) from notes query i didnt execute... by mistake i left it there..
Only query i executed is select * from notes where id = ...
so its just one query...
You can ignore the count(*) query
1
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 41843219
query_cache_type is off, so no caching is done.
http://dev.mysql.com/doc/refman/5.7/en/query-cache-configuration.html

so, you put this:
SET SESSION query_cache_type = ON;

to change that
1
 
LVL 21

Expert Comment

by:theGhost_k8
ID: 41843978
If you're using MySQL 5.7 and all InnoDB with proper indexing and bufferpool why would you worry about query cache!!! This has been very very old tutorial you must refer to understand the optimal size of query_cache for your systems:---> https://dom.as/tech/query-cache-tuner/ <-- Follow that for sure.

Also just saying that SET SESSION changes will vanish with the terminated connection. SET GLOBAL changes will vanish with mysqld restart. All persistent changes should be kept in config.
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Read about achieving the basic levels of HRIS security in the workplace.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now