ClickHouse/dbms/tests/queries/0_stateless/00836_indices_alter.sql

71 lines
1.7 KiB
MySQL
Raw Normal View History

2019-06-07 16:02:24 +00:00
DROP TABLE IF EXISTS minmax_idx;
DROP TABLE IF EXISTS minmax_idx2;
2019-01-16 17:59:47 +00:00
2019-02-12 17:54:52 +00:00
SET allow_experimental_data_skipping_indices = 1;
2019-06-07 16:02:24 +00:00
CREATE TABLE minmax_idx
2019-01-16 17:59:47 +00:00
(
u64 UInt64,
i32 Int32
) ENGINE = MergeTree()
ORDER BY u64;
2019-06-07 16:02:24 +00:00
INSERT INTO minmax_idx VALUES (1, 2);
2019-01-16 17:59:47 +00:00
2019-06-07 16:02:24 +00:00
ALTER TABLE minmax_idx ADD INDEX idx1 u64 * i32 TYPE minmax GRANULARITY 10;
ALTER TABLE minmax_idx ADD INDEX idx2 u64 + i32 TYPE minmax GRANULARITY 10;
ALTER TABLE minmax_idx ADD INDEX idx3 (u64 - i32) TYPE minmax GRANULARITY 10 AFTER idx1;
2019-01-16 17:59:47 +00:00
2019-06-07 16:02:24 +00:00
SHOW CREATE TABLE minmax_idx;
2019-01-16 17:59:47 +00:00
2019-06-07 16:02:24 +00:00
SELECT * FROM minmax_idx WHERE u64 * i32 = 2;
2019-01-16 17:59:47 +00:00
2019-06-07 16:02:24 +00:00
INSERT INTO minmax_idx VALUES (1, 2);
INSERT INTO minmax_idx VALUES (1, 2);
INSERT INTO minmax_idx VALUES (1, 2);
INSERT INTO minmax_idx VALUES (1, 2);
INSERT INTO minmax_idx VALUES (1, 2);
2019-01-16 17:59:47 +00:00
2019-06-07 16:02:24 +00:00
SELECT * FROM minmax_idx WHERE u64 * i32 = 2;
2019-01-16 17:59:47 +00:00
2019-06-07 16:02:24 +00:00
ALTER TABLE minmax_idx DROP INDEX idx1;
2019-01-16 17:59:47 +00:00
2019-06-07 16:02:24 +00:00
SHOW CREATE TABLE minmax_idx;
2019-01-16 17:59:47 +00:00
2019-06-07 16:02:24 +00:00
SELECT * FROM minmax_idx WHERE u64 * i32 = 2;
2019-01-16 17:59:47 +00:00
2019-06-07 16:02:24 +00:00
ALTER TABLE minmax_idx DROP INDEX idx2;
ALTER TABLE minmax_idx DROP INDEX idx3;
2019-01-16 17:59:47 +00:00
2019-06-07 16:02:24 +00:00
SHOW CREATE TABLE minmax_idx;
2019-01-16 17:59:47 +00:00
2019-06-07 16:02:24 +00:00
ALTER TABLE minmax_idx ADD INDEX idx1 (u64 * i32) TYPE minmax GRANULARITY 10;
2019-01-16 17:59:47 +00:00
2019-06-07 16:02:24 +00:00
SHOW CREATE TABLE minmax_idx;
2019-01-16 17:59:47 +00:00
2019-06-07 16:02:24 +00:00
SELECT * FROM minmax_idx WHERE u64 * i32 = 2;
2019-01-16 17:59:47 +00:00
2019-06-07 16:02:24 +00:00
CREATE TABLE minmax_idx2
2019-01-16 17:59:47 +00:00
(
u64 UInt64,
2019-01-21 13:51:42 +00:00
i32 Int32,
INDEX idx1 (u64 + i32) TYPE minmax GRANULARITY 10,
INDEX idx2 u64 * i32 TYPE minmax GRANULARITY 10
2019-01-16 17:59:47 +00:00
) ENGINE = MergeTree()
2019-01-21 13:51:42 +00:00
ORDER BY u64;
2019-01-16 17:59:47 +00:00
2019-06-07 16:02:24 +00:00
INSERT INTO minmax_idx2 VALUES (1, 2);
INSERT INTO minmax_idx2 VALUES (1, 2);
2019-01-16 17:59:47 +00:00
2019-06-07 16:02:24 +00:00
SELECT * FROM minmax_idx2 WHERE u64 * i32 = 2;
2019-01-16 17:59:47 +00:00
2019-06-07 16:02:24 +00:00
ALTER TABLE minmax_idx2 DROP INDEX idx1, DROP INDEX idx2;
2019-01-16 17:59:47 +00:00
2019-06-07 16:02:24 +00:00
SHOW CREATE TABLE minmax_idx2;
2019-01-16 17:59:47 +00:00
2019-06-07 16:02:24 +00:00
SELECT * FROM minmax_idx2 WHERE u64 * i32 = 2;
2019-01-16 17:59:47 +00:00
2019-06-07 16:02:24 +00:00
DROP TABLE minmax_idx;
DROP TABLE minmax_idx2;