Created
May 21, 2023 16:17
-
-
Save spetrunia/ae773ed2300d1cac543932a9e23bc9a1 to your computer and use it in GitHub Desktop.
Partitioned Tables Do Not Support ICP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MariaDB [(none)]> use test; | |
Database changed | |
MariaDB [test]> create table t1 (a int, b int, c int, key(b)) partition by hash(a) partitions 10; | |
Query OK, 0 rows affected (0.025 sec) | |
MariaDB [test]> show create table t1 \G | |
*************************** 1. row *************************** | |
Table: t1 | |
Create Table: CREATE TABLE `t1` ( | |
`a` int(11) DEFAULT NULL, | |
`b` int(11) DEFAULT NULL, | |
`c` int(11) DEFAULT NULL, | |
KEY `b` (`b`) | |
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci | |
PARTITION BY HASH (`a`) | |
PARTITIONS 10 | |
1 row in set (0.020 sec) | |
MariaDB [test]> insert into t1 select seq, seq, seq from seq_1_to_20000; | |
Query OK, 20000 rows affected (2.038 sec) | |
Records: 20000 Duplicates: 0 Warnings: 0 | |
MariaDB [test]> | |
MariaDB [test]> explain select * from t1 where b between 3 and 5 ; | |
+------+-------------+-------+-------+---------------+------+---------+------+------+-------------+ | |
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | | |
+------+-------------+-------+-------+---------------+------+---------+------+------+-------------+ | |
| 1 | SIMPLE | t1 | range | b | b | 5 | NULL | 10 | Using where | | |
+------+-------------+-------+-------+---------------+------+---------+------+------+-------------+ | |
1 row in set (0.005 sec) | |
MariaDB [test]> explain select * from t1 where b between 3 and 5 and (b+1) < (b+2); | |
+------+-------------+-------+-------+---------------+------+---------+------+------+-------------+ | |
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | | |
+------+-------------+-------+-------+---------------+------+---------+------+------+-------------+ | |
| 1 | SIMPLE | t1 | range | b | b | 5 | NULL | 10 | Using where | | |
+------+-------------+-------+-------+---------------+------+---------+------+------+-------------+ | |
1 row in set (0.005 sec) | |
MariaDB [test]> create table t2 (a int, b int, c int, key(b)); | |
Query OK, 0 rows affected (0.008 sec) | |
MariaDB [test]> insert into t2 select * from t1; | |
Query OK, 20000 rows affected (2.541 sec) | |
Records: 20000 Duplicates: 0 Warnings: 0 | |
MariaDB [test]> explain select * from t2 where b between 3 and 5 and (b+1) < (b+2); | |
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+ | |
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | | |
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+ | |
| 1 | SIMPLE | t2 | range | b | b | 5 | NULL | 3 | Using index condition | | |
+------+-------------+-------+-------+---------------+------+---------+------+------+-----------------------+ | |
1 row in set (0.001 sec) | |
MariaDB [test]> explain format=json select * from t2 where b between 3 and 5 and (b+1) < (b+2); | |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |
| EXPLAIN | | |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |
| { | |
"query_block": { | |
"select_id": 1, | |
"cost": 0.00787496, | |
"nested_loop": [ | |
{ | |
"table": { | |
"table_name": "t2", | |
"access_type": "range", | |
"possible_keys": ["b"], | |
"key": "b", | |
"key_length": "5", | |
"used_key_parts": ["b"], | |
"loops": 1, | |
"rows": 3, | |
"cost": 0.00787496, | |
"filtered": 100, | |
"index_condition": "t2.b between 3 and 5 and t2.b + 1 < t2.b + 2" | |
} | |
} | |
] | |
} | |
} | | |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |
1 row in set (0.003 sec) | |
MariaDB [test]> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment