Query_cache and column level privileges

August 6, 2007
Author
Vadim Tkachenko
Share this Post:

Recently we were puzzled by question how query_cache works with column level privileges. The question was appeared as we discovered function query_cache_send_result_to_client is called before real parsing of query, so at the moment of execution the query_cache is not able to know which columns are accessed.
Looking into source code I found out that in the case when table has column level privileges – function query_cache_send_result_to_client just stopped and returns to usual execution. So initial assumtion was that query against table with defined column privilege is just not cached, though it is not reflected in documentation.
It was worth to test it experimentally and the reality turned out more interesting.

under root:

and under user ‘vadim’

As you see the query was inserted into query cache with allocated memory for.

Let’s try second execution:

So query hits was not increased that proves the initial assumption – the query that includes tables with defined column level privileges can’t be cached – but actually even more – the query is stored in query cache area and eats memory, even the result cannot be used later.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Far
Enough.

Said no pioneer ever.
MySQL, PostgreSQL, InnoDB, MariaDB, MongoDB and Kubernetes are trademarks for their respective owners.
© 2026 Percona All Rights Reserved