File: opt_costmodel_myisam.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (61 lines) | stat: -rw-r--r-- 1,776 bytes parent folder | download
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
# Test needs MyISAM storage engine
--source include/force_myisam_default.inc
--source include/have_myisam.inc

--echo #
--echo # Bug#23508576 FILL_INDEXES_FROM_DD() DOES NOT INITIALIZE
--echo #              ST_KEY::M_IN_MEMORY_ESTIMATE
--echo #

# Adjust cost constants to be different for reading pages from a memory
# buffer compared to reading from disk.
# Cost for reading pages from memory to 0.5
UPDATE mysql.engine_cost
SET cost_value=0.5
WHERE cost_name="memory_block_read_cost";

# Cost for reading pages from disk to 2.0
UPDATE mysql.engine_cost
SET cost_value=2
WHERE cost_name="io_block_read_cost";

FLUSH OPTIMIZER_COSTS;

# Validate that the cost constants have been updated
SELECT engine_name, device_type, cost_name, cost_value
FROM mysql.engine_cost
WHERE cost_name="memory_block_read_cost"
   OR cost_name="io_block_read_cost";

# Table must be stored in a storage engine that does not provide
# estimates for how much of the index pages that are in a buffer
CREATE TABLE t1 (
  i1 INTEGER,
  c1 CHAR(200),
  INDEX idx (i1)
) ENGINE=MyISAM;

INSERT INTO t1 VALUES (1, "Ullensvang"), (2, "Odda"), (3, "Jondal");

# Create a user connection
connect (con1,localhost,root,,);

--echo # Pass criteria for the query plan:
--echo # 1. Should be executed as an index-only range scan
--echo # 2. Cost estimate: "read_cost" - "eval_cost" should be approximately
--echo #    the cost of reading one page from memory, ie. about 0.5.
--skip_if_hypergraph  # Depends on the query plan.
EXPLAIN FORMAT=JSON
SELECT i1 FROM t1 WHERE i1 > 1;

disconnect con1;
--source include/wait_until_disconnected.inc
connection default;

DROP TABLE t1;

# Reset cost constants for storage engines to default values
UPDATE mysql.engine_cost
SET cost_value=DEFAULT;

FLUSH OPTIMIZER_COSTS;