mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 20:42:30 +01:00
9f6a1c5842
Now partition engine adds underlying tables to the QC and ask underlying tables engine permittion to cache the query and return result of the query. Incorrect QC cleanup in case of table registration failure fixe. Unified interface for myisammrg & partitioned engnes for QC.
151 lines
4.1 KiB
Text
151 lines
4.1 KiB
Text
SET SESSION STORAGE_ENGINE = innodb;
|
|
drop table if exists t1;
|
|
set @save_query_cache_size = @@global.query_cache_size;
|
|
# Test that partitions works with query cache
|
|
flush query cache;
|
|
SET GLOBAL query_cache_size=1024*1024*512;
|
|
CREATE TABLE `t1` (
|
|
`id` int(11) NOT NULL ,
|
|
`created_at` datetime NOT NULL,
|
|
`cool` tinyint default 0
|
|
);
|
|
ALTER TABLE t1 PARTITION BY RANGE (TO_DAYS(created_at)) (
|
|
PARTITION month_2010_4 VALUES LESS THAN (734258),
|
|
PARTITION month_2010_5 VALUES LESS THAN (734289),
|
|
PARTITION month_max VALUES LESS THAN MAXVALUE
|
|
);
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`id` int(11) NOT NULL,
|
|
`created_at` datetime NOT NULL,
|
|
`cool` tinyint(4) DEFAULT '0'
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
/*!50100 PARTITION BY RANGE (TO_DAYS(created_at))
|
|
(PARTITION month_2010_4 VALUES LESS THAN (734258) ENGINE = InnoDB,
|
|
PARTITION month_2010_5 VALUES LESS THAN (734289) ENGINE = InnoDB,
|
|
PARTITION month_max VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
|
|
INSERT INTO t1 VALUES (1, now(), 0);
|
|
flush status;
|
|
show status like "Qcache_queries_in_cache";
|
|
Variable_name Value
|
|
Qcache_queries_in_cache 0
|
|
show status like "Qcache_hits";
|
|
Variable_name Value
|
|
Qcache_hits 0
|
|
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
|
cool
|
|
0
|
|
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
|
cool
|
|
0
|
|
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
|
cool
|
|
0
|
|
show status like "Qcache_queries_in_cache";
|
|
Variable_name Value
|
|
Qcache_queries_in_cache 1
|
|
show status like "Qcache_hits";
|
|
Variable_name Value
|
|
Qcache_hits 2
|
|
drop table t1;
|
|
# Test that sub-partitions works with query cache
|
|
flush query cache;
|
|
SET GLOBAL query_cache_size=1024*1024*512;
|
|
CREATE TABLE `t1` (
|
|
`id` int(11) NOT NULL ,
|
|
`created_at` datetime NOT NULL,
|
|
`cool` tinyint default 0
|
|
)
|
|
PARTITION BY RANGE (TO_DAYS(created_at))
|
|
subpartition by hash(cool) subpartitions 3 (
|
|
PARTITION month_2010_4 VALUES LESS THAN (734258),
|
|
PARTITION month_2010_5 VALUES LESS THAN (734289),
|
|
PARTITION month_max VALUES LESS THAN MAXVALUE
|
|
);
|
|
show create table t1;
|
|
Table Create Table
|
|
t1 CREATE TABLE `t1` (
|
|
`id` int(11) NOT NULL,
|
|
`created_at` datetime NOT NULL,
|
|
`cool` tinyint(4) DEFAULT '0'
|
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
|
/*!50100 PARTITION BY RANGE (TO_DAYS(created_at))
|
|
SUBPARTITION BY HASH (cool)
|
|
SUBPARTITIONS 3
|
|
(PARTITION month_2010_4 VALUES LESS THAN (734258) ENGINE = InnoDB,
|
|
PARTITION month_2010_5 VALUES LESS THAN (734289) ENGINE = InnoDB,
|
|
PARTITION month_max VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */
|
|
INSERT INTO t1 VALUES (1, now(), 0);
|
|
flush status;
|
|
show status like "Qcache_queries_in_cache";
|
|
Variable_name Value
|
|
Qcache_queries_in_cache 0
|
|
show status like "Qcache_hits";
|
|
Variable_name Value
|
|
Qcache_hits 0
|
|
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
|
cool
|
|
0
|
|
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
|
cool
|
|
0
|
|
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
|
cool
|
|
0
|
|
show status like "Qcache_queries_in_cache";
|
|
Variable_name Value
|
|
Qcache_queries_in_cache 1
|
|
show status like "Qcache_hits";
|
|
Variable_name Value
|
|
Qcache_hits 2
|
|
drop table t1;
|
|
#
|
|
# MySQL bug#53775 Query on partitioned table returns cached result
|
|
# from previous transaction
|
|
#
|
|
flush query cache;
|
|
flush status;
|
|
SET GLOBAL query_cache_size=1024*1024*512;
|
|
CREATE TABLE `t1` (
|
|
`id` int(11) NOT NULL ,
|
|
`created_at` datetime NOT NULL,
|
|
`cool` tinyint default 0
|
|
);
|
|
ALTER TABLE t1 PARTITION BY RANGE (TO_DAYS(created_at)) (
|
|
PARTITION month_2010_4 VALUES LESS THAN (734258),
|
|
PARTITION month_2010_5 VALUES LESS THAN (734289),
|
|
PARTITION month_max VALUES LESS THAN MAXVALUE
|
|
);
|
|
INSERT INTO t1 VALUES (1, now(), 0);
|
|
show status like "Qcache_queries_in_cache";
|
|
Variable_name Value
|
|
Qcache_queries_in_cache 0
|
|
show status like "Qcache_hits";
|
|
Variable_name Value
|
|
Qcache_hits 0
|
|
BEGIN;
|
|
UPDATE `t1` SET `cool` = 1 WHERE `id` = 1;
|
|
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
|
cool
|
|
1
|
|
ROLLBACK;
|
|
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
|
cool
|
|
0
|
|
BEGIN;
|
|
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
|
cool
|
|
0
|
|
ROLLBACK;
|
|
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
|
|
cool
|
|
0
|
|
show status like "Qcache_queries_in_cache";
|
|
Variable_name Value
|
|
Qcache_queries_in_cache 2
|
|
show status like "Qcache_hits";
|
|
Variable_name Value
|
|
Qcache_hits 1
|
|
drop table t1;
|
|
set @@global.query_cache_size = @save_query_cache_size;
|