File: query_cache_partitions.inc

package info (click to toggle)
mariadb-10.0 10.0.32-0%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 476,064 kB
  • sloc: cpp: 1,400,131; ansic: 832,140; perl: 54,391; sh: 41,304; pascal: 32,365; yacc: 14,921; xml: 5,257; sql: 4,667; cs: 4,647; makefile: 4,555; ruby: 4,465; python: 2,292; lex: 1,427; java: 941; asm: 295; awk: 54; php: 22; sed: 16
file content (126 lines) | stat: -rw-r--r-- 3,195 bytes parent folder | download | duplicates (4)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# include/query_cache_partitions.inc
#
# The variables
#     $engine_type       -- storage engine to be tested
# have to be set before sourcing this script.

eval SET SESSION STORAGE_ENGINE = $engine_type;

# Initialise
--disable_warnings
drop table if exists t1;
--enable_warnings

set @save_query_cache_size = @@global.query_cache_size;

--echo # 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;

INSERT INTO t1 VALUES (1, now(), 0);

flush status;
show status like "Qcache_queries_in_cache";
show status like "Qcache_hits";


SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;

show status like "Qcache_queries_in_cache";
show status like "Qcache_hits";

drop table t1;

--echo # 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;

INSERT INTO t1 VALUES (1, now(), 0);

flush status;
show status like "Qcache_queries_in_cache";
show status like "Qcache_hits";

SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;

show status like "Qcache_queries_in_cache";
show status like "Qcache_hits";

drop table t1;

--echo #
--echo # MySQL bug#53775 Query on partitioned table returns cached result
--echo # from previous transaction
--echo #

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";
show status like "Qcache_hits";

BEGIN;
UPDATE `t1` SET `cool` = 1 WHERE `id` = 1;
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
ROLLBACK;
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
BEGIN;
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;
ROLLBACK;
SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1;

show status like "Qcache_queries_in_cache";
show status like "Qcache_hits";

drop table t1;

set @@global.query_cache_size = @save_query_cache_size;