Skip to content

Commit a78a3ad

Browse files
author
Olav Sandstaa
committed
WL#7276 Configuration data base for Optimizer Cost Model
This worklogs adds two new tables to the "mysql" database for storing "cost constants" that will be used by the optimizer cost model. The two new tables are: - server_cost: This stores cost constants for server cost model. - engine_cost: For storing cost constants for the cost model for storage engines. The tables are created by the mysql_system_tables.sql script that is run when bootstrapping and upgrading the MySQL server.
1 parent 04e51dd commit a78a3ad

38 files changed

+791
-10
lines changed

mysql-test/r/1st.result

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ show tables in mysql;
99
Tables_in_mysql
1010
columns_priv
1111
db
12+
engine_cost
1213
event
1314
func
1415
general_log
@@ -24,6 +25,7 @@ plugin
2425
proc
2526
procs_priv
2627
proxies_priv
28+
server_cost
2729
servers
2830
slave_master_info
2931
slave_relay_log_info

mysql-test/r/connect.result

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ show tables;
33
Tables_in_mysql
44
columns_priv
55
db
6+
engine_cost
67
event
78
func
89
general_log
@@ -18,6 +19,7 @@ plugin
1819
proc
1920
procs_priv
2021
proxies_priv
22+
server_cost
2123
servers
2224
slave_master_info
2325
slave_relay_log_info
@@ -42,6 +44,7 @@ show tables;
4244
Tables_in_mysql
4345
columns_priv
4446
db
47+
engine_cost
4548
event
4649
func
4750
general_log
@@ -57,6 +60,7 @@ plugin
5760
proc
5861
procs_priv
5962
proxies_priv
63+
server_cost
6064
servers
6165
slave_master_info
6266
slave_relay_log_info

mysql-test/r/information_schema.result

+3-1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ USER_PRIVILEGES
8686
VIEWS
8787
columns_priv
8888
db
89+
engine_cost
8990
event
9091
func
9192
general_log
@@ -98,6 +99,7 @@ plugin
9899
proc
99100
procs_priv
100101
proxies_priv
102+
server_cost
101103
servers
102104
slave_master_info
103105
slave_relay_log_info
@@ -903,7 +905,7 @@ AND table_name not like 'ndb%' AND table_name not like 'innodb_%'
903905
GROUP BY TABLE_SCHEMA;
904906
table_schema count(*)
905907
information_schema 31
906-
mysql 26
908+
mysql 28
907909
create table t1 (i int, j int);
908910
create trigger trg1 before insert on t1 for each row
909911
begin

mysql-test/r/log_tables_upgrade.result

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ RENAME TABLE general_log TO renamed_general_log;
1313
RENAME TABLE test.bug49823 TO general_log;
1414
mysql.columns_priv OK
1515
mysql.db OK
16+
mysql.engine_cost OK
1617
mysql.event OK
1718
mysql.func OK
1819
mysql.general_log OK
@@ -29,6 +30,7 @@ mysql.proc OK
2930
mysql.procs_priv OK
3031
mysql.proxies_priv OK
3132
mysql.renamed_general_log OK
33+
mysql.server_cost OK
3234
mysql.servers OK
3335
mysql.slave_master_info OK
3436
mysql.slave_relay_log_info OK

mysql-test/r/mysql_upgrade.result

+54
Large diffs are not rendered by default.

mysql-test/r/mysql_upgrade_ssl.result

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#
44
mysql.columns_priv OK
55
mysql.db OK
6+
mysql.engine_cost OK
67
mysql.event OK
78
mysql.func OK
89
mysql.general_log OK
@@ -18,6 +19,7 @@ mysql.plugin OK
1819
mysql.proc OK
1920
mysql.procs_priv OK
2021
mysql.proxies_priv OK
22+
mysql.server_cost OK
2123
mysql.servers OK
2224
mysql.slave_master_info OK
2325
mysql.slave_relay_log_info OK

mysql-test/r/mysqlcheck.result

+16
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ mtr.global_suppressions OK
55
mtr.test_suppressions OK
66
mysql.columns_priv OK
77
mysql.db OK
8+
mysql.engine_cost OK
89
mysql.event OK
910
mysql.func OK
1011
mysql.general_log
@@ -21,6 +22,7 @@ mysql.plugin OK
2122
mysql.proc OK
2223
mysql.procs_priv OK
2324
mysql.proxies_priv OK
25+
mysql.server_cost OK
2426
mysql.servers OK
2527
mysql.slave_master_info OK
2628
mysql.slave_relay_log_info OK
@@ -38,6 +40,9 @@ mtr.global_suppressions Table is already up to date
3840
mtr.test_suppressions Table is already up to date
3941
mysql.columns_priv OK
4042
mysql.db OK
43+
mysql.engine_cost
44+
note : Table does not support optimize, doing recreate + analyze instead
45+
status : OK
4146
mysql.event OK
4247
mysql.func OK
4348
mysql.general_log
@@ -68,6 +73,9 @@ mysql.plugin OK
6873
mysql.proc OK
6974
mysql.procs_priv OK
7075
mysql.proxies_priv OK
76+
mysql.server_cost
77+
note : Table does not support optimize, doing recreate + analyze instead
78+
status : OK
7179
mysql.servers OK
7280
mysql.slave_master_info
7381
note : Table does not support optimize, doing recreate + analyze instead
@@ -99,6 +107,7 @@ status : OK
99107
mysql.user OK
100108
mysql.columns_priv OK
101109
mysql.db OK
110+
mysql.engine_cost OK
102111
mysql.event OK
103112
mysql.func OK
104113
mysql.general_log
@@ -115,6 +124,7 @@ mysql.plugin OK
115124
mysql.proc OK
116125
mysql.procs_priv OK
117126
mysql.proxies_priv OK
127+
mysql.server_cost OK
118128
mysql.servers OK
119129
mysql.slave_master_info OK
120130
mysql.slave_relay_log_info OK
@@ -130,6 +140,9 @@ mysql.time_zone_transition_type OK
130140
mysql.user OK
131141
mysql.columns_priv Table is already up to date
132142
mysql.db Table is already up to date
143+
mysql.engine_cost
144+
note : Table does not support optimize, doing recreate + analyze instead
145+
status : OK
133146
mysql.event Table is already up to date
134147
mysql.func Table is already up to date
135148
mysql.general_log
@@ -160,6 +173,9 @@ mysql.plugin Table is already up to date
160173
mysql.proc Table is already up to date
161174
mysql.procs_priv Table is already up to date
162175
mysql.proxies_priv Table is already up to date
176+
mysql.server_cost
177+
note : Table does not support optimize, doing recreate + analyze instead
178+
status : OK
163179
mysql.servers Table is already up to date
164180
mysql.slave_master_info
165181
note : Table does not support optimize, doing recreate + analyze instead

mysql-test/r/opt_costmodel.result

+143
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
SELECT * FROM mysql.server_cost;
2+
cost_name cost_value last_update comment
3+
disk_temptable_create_cost NULL # NULL
4+
disk_temptable_row_cost NULL # NULL
5+
key_compare_cost NULL # NULL
6+
memory_temptable_create_cost NULL # NULL
7+
memory_temptable_row_cost NULL # NULL
8+
row_evaluate_cost NULL # NULL
9+
SHOW INDEX FROM mysql.server_cost;
10+
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
11+
server_cost 0 PRIMARY 1 cost_name A # NULL NULL BTREE
12+
SELECT * FROM mysql.engine_cost;
13+
engine_name device_type cost_name cost_value last_update comment
14+
default 0 io_block_read_cost NULL # NULL
15+
SHOW INDEX FROM mysql.engine_cost;
16+
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
17+
engine_cost 0 PRIMARY 1 cost_name A # NULL NULL BTREE
18+
engine_cost 0 PRIMARY 2 engine_name A # NULL NULL BTREE
19+
engine_cost 0 PRIMARY 3 device_type A # NULL NULL BTREE
20+
UPDATE mysql.server_cost
21+
SET cost_value=0.1
22+
WHERE cost_name="row_evaluate_cost";
23+
SELECT *
24+
FROM mysql.server_cost
25+
WHERE cost_name="row_evaluate_cost";
26+
cost_name cost_value last_update comment
27+
row_evaluate_cost 0.1 # NULL
28+
UPDATE mysql.server_cost
29+
SET cost_value=DEFAULT
30+
WHERE cost_name="row_evaluate_cost";
31+
SELECT *
32+
FROM mysql.server_cost
33+
WHERE cost_name="row_evaluate_cost";
34+
cost_name cost_value last_update comment
35+
row_evaluate_cost NULL # NULL
36+
INSERT INTO mysql.server_cost
37+
VALUES ("lunch_cost", DEFAULT, CURRENT_TIMESTAMP, "Lunch is important");
38+
SELECT * FROM mysql.server_cost;
39+
cost_name cost_value last_update comment
40+
disk_temptable_create_cost NULL # NULL
41+
disk_temptable_row_cost NULL # NULL
42+
key_compare_cost NULL # NULL
43+
lunch_cost NULL # Lunch is important
44+
memory_temptable_create_cost NULL # NULL
45+
memory_temptable_row_cost NULL # NULL
46+
row_evaluate_cost NULL # NULL
47+
DELETE FROM mysql.server_cost
48+
WHERE cost_name="lunch_cost";
49+
INSERT INTO mysql.server_cost
50+
VALUES ("row_evaluate_cost", DEFAULT, CURRENT_TIMESTAMP, "Faster CPU");
51+
ERROR 23000: Duplicate entry 'row_evaluate_cost' for key 'PRIMARY'
52+
INSERT INTO mysql.server_cost
53+
VALUES ("ROW_EVALUATE_COST", DEFAULT, CURRENT_TIMESTAMP, "Faster CPU");
54+
ERROR 23000: Duplicate entry 'ROW_EVALUATE_COST' for key 'PRIMARY'
55+
SELECT * FROM mysql.server_cost;
56+
cost_name cost_value last_update comment
57+
disk_temptable_create_cost NULL # NULL
58+
disk_temptable_row_cost NULL # NULL
59+
key_compare_cost NULL # NULL
60+
memory_temptable_create_cost NULL # NULL
61+
memory_temptable_row_cost NULL # NULL
62+
row_evaluate_cost NULL # NULL
63+
UPDATE mysql.engine_cost
64+
SET cost_value=0.1
65+
WHERE cost_name="io_block_read_cost";
66+
SELECT *
67+
FROM mysql.engine_cost
68+
WHERE cost_name="io_block_read_cost";
69+
engine_name device_type cost_name cost_value last_update comment
70+
default 0 io_block_read_cost 0.1 # NULL
71+
UPDATE mysql.engine_cost
72+
SET cost_value=DEFAULT
73+
WHERE cost_name="io_block_read_cost";
74+
SELECT *
75+
FROM mysql.engine_cost
76+
WHERE cost_name="io_block_read_cost";
77+
engine_name device_type cost_name cost_value last_update comment
78+
default 0 io_block_read_cost NULL # NULL
79+
INSERT INTO mysql.engine_cost
80+
VALUES ("InnoDB", 2, "lunch_cost1", DEFAULT, CURRENT_TIMESTAMP, "Lunch 1"),
81+
("InnoDB", 2, "lunch_cost2", DEFAULT, CURRENT_TIMESTAMP, "Lunch 2");
82+
SELECT * FROM mysql.engine_cost;
83+
engine_name device_type cost_name cost_value last_update comment
84+
default 0 io_block_read_cost NULL # NULL
85+
InnoDB 2 lunch_cost1 NULL # Lunch 1
86+
InnoDB 2 lunch_cost2 NULL # Lunch 2
87+
DELETE FROM mysql.engine_cost
88+
WHERE cost_name LIKE "lunch_cost%";
89+
INSERT INTO mysql.engine_cost
90+
VALUES ("default", 0, "lunch_cost", DEFAULT, CURRENT_TIMESTAMP, "Lunch");
91+
INSERT INTO mysql.engine_cost
92+
VALUES ("default", 0, "lunch_cost", DEFAULT, CURRENT_TIMESTAMP, "Lunch");
93+
ERROR 23000: Duplicate entry 'lunch_cost-default-0' for key 'PRIMARY'
94+
SELECT * FROM mysql.engine_cost;
95+
engine_name device_type cost_name cost_value last_update comment
96+
default 0 io_block_read_cost NULL # NULL
97+
default 0 lunch_cost NULL # Lunch
98+
DELETE FROM mysql.engine_cost
99+
WHERE cost_name="lunch_cost";
100+
INSERT INTO mysql.engine_cost
101+
VALUES ("default", 0, "IO_BLOCK_READ_COST", DEFAULT, CURRENT_TIMESTAMP,
102+
"Lunch");
103+
ERROR 23000: Duplicate entry 'IO_BLOCK_READ_COST-default-0' for key 'PRIMARY'
104+
SELECT * FROM mysql.engine_cost;
105+
engine_name device_type cost_name cost_value last_update comment
106+
default 0 io_block_read_cost NULL # NULL
107+
CREATE TABLE server_cost_tmp (
108+
cost_name VARCHAR(64) NOT NULL,
109+
last_update TIMESTAMP
110+
);
111+
CREATE TABLE engine_cost_tmp (
112+
cost_name VARCHAR(64) NOT NULL,
113+
last_update TIMESTAMP
114+
);
115+
INSERT INTO server_cost_tmp
116+
SELECT cost_name, last_update FROM mysql.server_cost;
117+
INSERT INTO engine_cost_tmp
118+
SELECT cost_name, last_update FROM mysql.engine_cost;
119+
UPDATE mysql.server_cost
120+
SET cost_value=0.1
121+
WHERE cost_name="row_evaluate_cost";
122+
SELECT mysql.server_cost.cost_name
123+
FROM mysql.server_cost JOIN server_cost_tmp
124+
ON mysql.server_cost.cost_name = server_cost_tmp.cost_name
125+
WHERE mysql.server_cost.last_update > server_cost_tmp.last_update;
126+
cost_name
127+
row_evaluate_cost
128+
UPDATE mysql.server_cost
129+
SET cost_value=DEFAULT
130+
WHERE cost_name="row_evaluate_cost";
131+
UPDATE mysql.engine_cost
132+
SET cost_value=2.0
133+
WHERE cost_name="io_block_read_cost";
134+
SELECT mysql.engine_cost.cost_name
135+
FROM mysql.engine_cost JOIN engine_cost_tmp
136+
ON mysql.engine_cost.cost_name = engine_cost_tmp.cost_name
137+
WHERE mysql.engine_cost.last_update > engine_cost_tmp.last_update;
138+
cost_name
139+
io_block_read_cost
140+
UPDATE mysql.engine_cost
141+
SET cost_value=DEFAULT
142+
WHERE cost_name="io_block_read_cost";
143+
DROP TABLE server_cost_tmp, engine_cost_tmp;

mysql-test/r/plugin_auth.result

+4
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ DROP USER u1@localhost,u2@localhost;
316316
FLUSH PRIVILEGES;
317317
mysql.columns_priv OK
318318
mysql.db OK
319+
mysql.engine_cost OK
319320
mysql.event OK
320321
mysql.func OK
321322
mysql.general_log OK
@@ -330,6 +331,7 @@ mysql.ndb_binlog_index OK
330331
mysql.plugin OK
331332
mysql.proc OK
332333
mysql.procs_priv OK
334+
mysql.server_cost OK
333335
mysql.servers OK
334336
mysql.slave_master_info OK
335337
mysql.slave_relay_log_info OK
@@ -449,6 +451,7 @@ ALTER TABLE mysql.user MODIFY authentication_string TEXT NOT NULL;
449451
Run mysql_upgrade on a 5.5.10 external authentication column layout
450452
mysql.columns_priv OK
451453
mysql.db OK
454+
mysql.engine_cost OK
452455
mysql.event OK
453456
mysql.func OK
454457
mysql.general_log OK
@@ -464,6 +467,7 @@ mysql.plugin OK
464467
mysql.proc OK
465468
mysql.procs_priv OK
466469
mysql.proxies_priv OK
470+
mysql.server_cost OK
467471
mysql.servers OK
468472
mysql.slave_master_info OK
469473
mysql.slave_relay_log_info OK

mysql-test/r/system_mysql_db.result

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ show tables;
22
Tables_in_db
33
columns_priv
44
db
5+
engine_cost
56
event
67
func
78
general_log
@@ -17,6 +18,7 @@ plugin
1718
proc
1819
procs_priv
1920
proxies_priv
21+
server_cost
2022
servers
2123
slave_master_info
2224
slave_relay_log_info

mysql-test/r/wl6219-upgrade.result

+2
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ DROP TABLE t1;
166166
#
167167
mysql.columns_priv OK
168168
mysql.db OK
169+
mysql.engine_cost OK
169170
mysql.event OK
170171
mysql.func OK
171172
mysql.general_log OK
@@ -181,6 +182,7 @@ mysql.plugin OK
181182
mysql.proc OK
182183
mysql.procs_priv OK
183184
mysql.proxies_priv OK
185+
mysql.server_cost OK
184186
mysql.servers OK
185187
mysql.slave_master_info OK
186188
mysql.slave_relay_log_info OK

0 commit comments

Comments
 (0)