-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51734 from ClickHouse/backport/23.6/51610
Backport #51610 to 23.6: Fix for moving 'IN' conditions to PREWHERE
- Loading branch information
Showing
13 changed files
with
126 additions
and
13 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
PREWHERE a IN | ||
PREWHERE a IN | ||
PREWHERE a IN | ||
PREWHERE a IN | ||
PREWHERE b NOT IN | ||
PREWHERE b NOT IN | ||
PREWHERE b NOT IN | ||
PREWHERE b NOT IN |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
DROP TABLE IF EXISTS t_02809; | ||
|
||
CREATE TABLE t_02809(a Int64, b Int64, s String) | ||
ENGINE=MergeTree order by tuple() | ||
AS SELECT number, number%10, toString(arrayMap(i-> cityHash64(i*number), range(50))) FROM numbers(10000); | ||
|
||
CREATE TABLE t_02809_set(c Int64) | ||
ENGINE=Set() | ||
AS SELECT * FROM numbers(10); | ||
|
||
CREATE TABLE t_02809_aux(c Int64) | ||
ENGINE=Memory() | ||
AS SELECT * FROM numbers(10); | ||
|
||
|
||
SET optimize_move_to_prewhere=1; | ||
|
||
-- Queries with 'IN' | ||
SELECT substring(explain, 1, 13) FROM (EXPLAIN SYNTAX | ||
SELECT * FROM t_02809 WHERE a IN (SELECT * FROM system.one) | ||
) WHERE explain LIKE '%WHERE%'; | ||
|
||
SELECT substring(explain, 1, 13) FROM (EXPLAIN SYNTAX | ||
SELECT * FROM t_02809 WHERE a IN (1,2,3) | ||
) WHERE explain LIKE '%WHERE%'; | ||
|
||
SELECT substring(explain, 1, 13) FROM (EXPLAIN SYNTAX | ||
SELECT * FROM t_02809 WHERE a IN t_02809_set | ||
) WHERE explain LIKE '%WHERE%'; | ||
|
||
SELECT substring(explain, 1, 13) FROM (EXPLAIN SYNTAX | ||
SELECT * FROM t_02809 WHERE a IN t_02809_aux | ||
) WHERE explain LIKE '%WHERE%'; | ||
|
||
|
||
-- Queries with 'NOT IN' | ||
SELECT substring(explain, 1, 17) FROM (EXPLAIN SYNTAX | ||
SELECT * FROM t_02809 WHERE b NOT IN (SELECT * FROM system.one) | ||
) WHERE explain LIKE '%WHERE%'; | ||
|
||
SELECT substring(explain, 1, 17) FROM (EXPLAIN SYNTAX | ||
SELECT * FROM t_02809 WHERE b NOT IN (1,2,3) | ||
) WHERE explain LIKE '%WHERE%'; | ||
|
||
SELECT substring(explain, 1, 17) FROM (EXPLAIN SYNTAX | ||
SELECT * FROM t_02809 WHERE b NOT IN t_02809_set | ||
) WHERE explain LIKE '%WHERE%'; | ||
|
||
SELECT substring(explain, 1, 17) FROM (EXPLAIN SYNTAX | ||
SELECT * FROM t_02809 WHERE b NOT IN t_02809_aux | ||
) WHERE explain LIKE '%WHERE%'; | ||
|
||
|
||
DROP TABLE t_02809; | ||
DROP TABLE t_02809_set; | ||
DROP TABLE t_02809_aux; |