August 24th, 2012, 07:47 AM
Join Date: Sep 2005
Time spent in forums: 1 Day 4 h 8 m 59 sec
Reputation Power: 8
Caching MySQL UNION Queries
I've read that MySQL can cache `UNION's`, but at the same time I have read that..
| Avoid comment (and space) in the start of the query – Query Cache does simple optimization to check if query can be cached. As I mentioned only SELECT queries are cached – so it looks at first letter of the query and if it is “S” it proceeds with query lookup in cache if not – skips it. |
So with that said, since UNION's start with a parentheses how are they cached?
As per MySQL:
(SELECT a FROM t1 WHERE a=10 AND B=1 ORDER BY a LIMIT 10)
(SELECT a FROM t2 WHERE a=11 AND B=2 ORDER BY a LIMIT 10);
First letter is NOT an "S", so it would be skipped!?
So how do UNION's get cached then?