2021-11-10 17:57:59 +00:00
|
|
|
SET convert_query_to_cnf = 1;
|
|
|
|
SET optimize_using_constraints = 1;
|
2023-11-30 18:19:26 +00:00
|
|
|
SET optimize_append_index = 0;
|
2021-11-10 17:57:59 +00:00
|
|
|
|
|
|
|
DROP TABLE IF EXISTS t_constraints_where;
|
|
|
|
|
|
|
|
CREATE TABLE t_constraints_where(a UInt32, b UInt32, CONSTRAINT c1 ASSUME b >= 5, CONSTRAINT c2 ASSUME b <= 10) ENGINE = Memory;
|
|
|
|
|
|
|
|
INSERT INTO t_constraints_where VALUES (1, 7);
|
|
|
|
|
|
|
|
EXPLAIN SYNTAX SELECT count() FROM t_constraints_where WHERE b > 15; -- assumption -> 0
|
2023-04-02 23:06:26 +00:00
|
|
|
EXPLAIN QUERY TREE SELECT count() FROM t_constraints_where WHERE b > 15 SETTINGS allow_experimental_analyzer = 1; -- assumption -> 0
|
2021-11-10 17:57:59 +00:00
|
|
|
EXPLAIN SYNTAX SELECT count() FROM t_constraints_where WHERE b = 20; -- assumption -> 0
|
2023-04-02 23:06:26 +00:00
|
|
|
EXPLAIN QUERY TREE SELECT count() FROM t_constraints_where WHERE b = 20 SETTINGS allow_experimental_analyzer = 1; -- assumption -> 0
|
2021-11-10 17:57:59 +00:00
|
|
|
EXPLAIN SYNTAX SELECT count() FROM t_constraints_where WHERE b < 2; -- assumption -> 0
|
2023-04-02 23:06:26 +00:00
|
|
|
EXPLAIN QUERY TREE SELECT count() FROM t_constraints_where WHERE b < 2 SETTINGS allow_experimental_analyzer = 1; -- assumption -> 0
|
2021-11-10 17:57:59 +00:00
|
|
|
EXPLAIN SYNTAX SELECT count() FROM t_constraints_where WHERE b > 20 OR b < 8; -- assumption -> remove (b < 20)
|
2023-04-02 23:06:26 +00:00
|
|
|
EXPLAIN QUERY TREE SELECT count() FROM t_constraints_where WHERE b > 20 OR b < 8 SETTINGS allow_experimental_analyzer = 1; -- assumption -> remove (b < 20)
|
2023-03-28 08:12:21 +00:00
|
|
|
EXPLAIN SYNTAX SELECT count() FROM t_constraints_where PREWHERE b > 20 OR b < 8; -- assumption -> remove (b < 20)
|
2023-04-02 23:06:26 +00:00
|
|
|
EXPLAIN QUERY TREE SELECT count() FROM t_constraints_where PREWHERE b > 20 OR b < 8 SETTINGS allow_experimental_analyzer = 1; -- assumption -> remove (b < 20)
|
2021-11-10 17:57:59 +00:00
|
|
|
|
|
|
|
DROP TABLE t_constraints_where;
|
|
|
|
|
|
|
|
CREATE TABLE t_constraints_where(a UInt32, b UInt32, CONSTRAINT c1 ASSUME b < 10) ENGINE = Memory;
|
|
|
|
|
|
|
|
INSERT INTO t_constraints_where VALUES (1, 7);
|
|
|
|
|
2023-03-16 15:59:48 +00:00
|
|
|
EXPLAIN SYNTAX SELECT count() FROM t_constraints_where WHERE b = 1 OR b < 18 OR b > 5; -- assumption -> (b < 20) -> 0;
|
2023-04-02 23:06:26 +00:00
|
|
|
EXPLAIN QUERY TREE SELECT count() FROM t_constraints_where WHERE b = 1 OR b < 18 OR b > 5 SETTINGS allow_experimental_analyzer = 1; -- assumption -> (b < 20) -> 0;
|
2021-11-10 17:57:59 +00:00
|
|
|
|
|
|
|
DROP TABLE t_constraints_where;
|