Revenue Source

Welcome to the Revenue Source affiliate marketing forums.

You are viewing our internet marketing and SEO forums as a guest which gives you limited access to most of our discussions.  By joining our free community, you will have access to post affiliate marketing topics, communicate privately with other members (PM), exchange SEO strategies, and access many other special features.  Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems, please don't hesitate to contact us.

Go Back   Revenue Source > Site Design & Development > Databases
Reload this Page Query_cache and column level privileges
Tags: , , ,

Reply
 
LinkBack Thread Tools Search this Thread
Old
  (#1 (permalink))
Affiliate Blogs is Offline
Revenue Source Veteran
Affiliate Blogs has a brilliant future here!
 
Affiliate Blogs's Avatar
 
Join Date: Oct 2005
Posts: 9,212
Jack of All Trades
CyberSpace United States
   
Query_cache and column level privileges - 08-06-2007

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:
PLAIN TEXT
SQL:
  1. [FONT='Courier New', Courier, monospace]CREATE TABLE xp.test1 (id int, name varchar(23));[/font]
  2. [FONT='Courier New', Courier, monospace]INSERT INTO xp.test1 VALUES (5, 'testit');[/font]
  3. [FONT='Courier New', Courier, monospace]GRANT SELECT (id) ON TABLE xp.test1 TO 'vadim'@'localhost'; [/font]



and under user 'vadim'
PLAIN TEXT
SQL:
  1. [FONT='Courier New', Courier, monospace]Before query execution:[/font]
  2. [FONT='Courier New', Courier, monospace]mysql> SHOW global STATUS LIKE 'qcache%';[/font]
  3. [FONT='Courier New', Courier, monospace]+-------------------------+----------+[/font]
  4. [FONT='Courier New', Courier, monospace]| Variable_name | Value |[/font]
  5. [FONT='Courier New', Courier, monospace]+-------------------------+----------+[/font]
  6. [FONT='Courier New', Courier, monospace]| Qcache_free_memory | 67091176 | [/font]
  7. [FONT='Courier New', Courier, monospace]| Qcache_hits | 0 | [/font]
  8. [FONT='Courier New', Courier, monospace]| Qcache_inserts | 0 | [/font]
  9. [FONT='Courier New', Courier, monospace]| Qcache_queries_in_cache | 0 | [/font]
  10. [FONT='Courier New', Courier, monospace]+-------------------------+----------+[/font]
  11. [FONT='Courier New', Courier, monospace]8 rows IN SET (0.01 sec)[/font]
  12. [FONT='Courier New', Courier, monospace]Query:[/font]
  13. [FONT='Courier New', Courier, monospace]mysql> SELECT id FROM xp.test1 WHERE id> 1;[/font]
  14. [FONT='Courier New', Courier, monospace]+------+[/font]
  15. [FONT='Courier New', Courier, monospace]| id |[/font]
  16. [FONT='Courier New', Courier, monospace]+------+[/font]
  17. [FONT='Courier New', Courier, monospace]| 5 | [/font]
  18. [FONT='Courier New', Courier, monospace]+------+[/font]
  19. [FONT='Courier New', Courier, monospace]1 row IN SET (0.00 sec)[/font]
  20. [FONT='Courier New', Courier, monospace]After query execution:[/font]
  21. [FONT='Courier New', Courier, monospace]mysql> SHOW global STATUS LIKE 'qcache%'; [/font]
  22. [FONT='Courier New', Courier, monospace]+-------------------------+----------+[/font]
  23. [FONT='Courier New', Courier, monospace]| Variable_name | Value |[/font]
  24. [FONT='Courier New', Courier, monospace]+-------------------------+----------+[/font]
  25. [FONT='Courier New', Courier, monospace]| Qcache_free_memory | 67089640 | [/font]
  26. [FONT='Courier New', Courier, monospace]| Qcache_hits | 0 | [/font]
  27. [FONT='Courier New', Courier, monospace]| Qcache_inserts | 1 | [/font]
  28. [FONT='Courier New', Courier, monospace]| Qcache_queries_in_cache | 1 | [/font]
  29. [FONT='Courier New', Courier, monospace]+-------------------------+----------+ [/font]



As you see the query was inserted into query cache with allocated memory for.
Let's try second execution:
PLAIN TEXT
SQL:
  1. [FONT='Courier New', Courier, monospace]8 rows IN SET (0.01 sec)[/font]
  2. [FONT='Courier New', Courier, monospace]mysql> SELECT id FROM xp.test1 WHERE id> 1;[/font]
  3. [FONT='Courier New', Courier, monospace]+------+[/font]
  4. [FONT='Courier New', Courier, monospace]| id |[/font]
  5. [FONT='Courier New', Courier, monospace]+------+[/font]
  6. [FONT='Courier New', Courier, monospace]| 5 | [/font]
  7. [FONT='Courier New', Courier, monospace]+------+[/font]
  8. [FONT='Courier New', Courier, monospace]1 row IN SET (0.00 sec)[/font]
  9. [FONT='Courier New', Courier, monospace] [/font]
  10. [FONT='Courier New', Courier, monospace]mysql> SHOW global STATUS LIKE 'qcache%'; [/font]
  11. [FONT='Courier New', Courier, monospace]+-------------------------+----------+[/font]
  12. [FONT='Courier New', Courier, monospace]| Variable_name | Value |[/font]
  13. [FONT='Courier New', Courier, monospace]+-------------------------+----------+[/font]
  14. [FONT='Courier New', Courier, monospace]| Qcache_free_memory | 67089640 | [/font]
  15. [FONT='Courier New', Courier, monospace]| Qcache_hits | 0 | [/font]
  16. [FONT='Courier New', Courier, monospace]| Qcache_inserts | 1 | [/font]
  17. [FONT='Courier New', Courier, monospace]| Qcache_queries_in_cache | 1 | [/font]
  18. [FONT='Courier New', Courier, monospace]+-------------------------+----------+[/font]
  19. [FONT='Courier New', Courier, monospace]8 rows IN SET (0.02 sec) [/font]



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.


Query_cache and column level privileges - Read More...
  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads for: Query_cache and column level privileges
Thread Thread Starter Forum Replies Last Post
Add Column Affiliate Blogs Programming Help 0 04-27-2007 02:31 PM
Beware large Query_Cache sizes Affiliate Blogs Databases 0 03-23-2007 08:57 PM
Taking Video to the Next Level aviener Affiliate Marketing 0 02-02-2007 06:17 PM
Don't Dulpicate a Column Affiliate Blogs Programming Help 0 01-10-2007 05:05 PM
Add Column Affiliate Blogs Programming Help 0 11-16-2006 09:23 PM



© 2004-6 RevenueSource.com.  All rights reserved.  Do not duplicate or redistribute in any form.
This website and its logos/design are property of RevenueSource.com.  All rights reserved. vBSEO 3.2.0 RC7


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34