diff --git a/tests/performance/all_join_opt.xml b/tests/performance/all_join_opt.xml
index ed8805a2e5f..0ab9c39f67c 100644
--- a/tests/performance/all_join_opt.xml
+++ b/tests/performance/all_join_opt.xml
@@ -5,8 +5,8 @@
INSERT INTO test SELECT number % 10000, number % 10000, number % 10000 FROM numbers(10000000)
INSERT INTO test1 SELECT number % 1000 , number % 1000, number % 1000 FROM numbers(100000)
- SELECT MAX(test1.a) FROM test INNER JOIN test1 on test.b = test1.b SETTINGS allow_experimental_inner_join_right_table_sorting=true, join_to_sort_table_rows_threshold=100000
- SELECT MAX(test1.a) FROM test LEFT JOIN test1 on test.b = test1.b SETTINGS allow_experimental_inner_join_right_table_sorting=true, join_to_sort_table_rows_threshold=100000
+ SELECT MAX(test1.a) FROM test INNER JOIN test1 on test.b = test1.b
+ SELECT MAX(test1.a) FROM test LEFT JOIN test1 on test.b = test1.b
SELECT MAX(test1.a) FROM test RIGHT JOIN test1 on test.b = test1.b
SELECT MAX(test1.a) FROM test FULL JOIN test1 on test.b = test1.b
diff --git a/tests/queries/0_stateless/03228_join_to_rerange_right_table.reference b/tests/queries/0_stateless/03228_join_to_rerange_right_table.reference
new file mode 100644
index 00000000000..b62923296e5
--- /dev/null
+++ b/tests/queries/0_stateless/03228_join_to_rerange_right_table.reference
@@ -0,0 +1,2 @@
+9
+9
diff --git a/tests/queries/0_stateless/03228_join_to_rerange_right_table.sql b/tests/queries/0_stateless/03228_join_to_rerange_right_table.sql
new file mode 100644
index 00000000000..e9001f92405
--- /dev/null
+++ b/tests/queries/0_stateless/03228_join_to_rerange_right_table.sql
@@ -0,0 +1,14 @@
+drop table if exists test_left;
+drop table if exists test_right;
+
+CREATE TABLE test_left (a Int64, b String, c LowCardinality(String)) ENGINE = MergeTree() ORDER BY a;
+CREATE TABLE test_right (a Int64, b String, c LowCardinality(String)) ENGINE = MergeTree() ORDER BY a;
+
+INSERT INTO test_left SELECT number % 10000, number % 10000, number % 10000 FROM numbers(100000);
+INSERT INTO test_right SELECT number % 10 , number % 10, number % 10 FROM numbers(10000);
+
+SELECT MAX(test_right.a) FROM test_left INNER JOIN test_right on test_left.b = test_right.b SETTINGS allow_experimental_inner_join_right_table_sorting=true;
+SELECT MAX(test_right.a) FROM test_left LEFT JOIN test_right on test_left.b = test_right.b SETTINGS allow_experimental_inner_join_right_table_sorting=true;
+
+drop table test_left;
+drop table test_right;