You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by al...@apache.org on 2026/10/03 02:06:04 UTC

(asterixdb) branch master updated: [ASTERIXDB-3916][COMP] Cover IN lists and composite bounds on untyped indexes

This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git


The following commit(s) were added to refs/heads/master by this push:
     new f40604c854 [ASTERIXDB-3916][COMP] Cover IN lists and composite bounds on untyped indexes
f40604c854 is described below

commit f40604c8540373cf38a6354e0d8a720da214e494
Author: Ali Alsuliman <al...@gmail.com>
AuthorDate: Mon Sep 28 09:32:30 2026 -0700

    [ASTERIXDB-3916][COMP] Cover IN lists and composite bounds on untyped indexes
    
    - user model changes: no
    - storage format changes: no
    - interface changes: no
    
    Details: an untyped index on a collection with no declared fields takes
    paths the earlier tests, on typed indexes or declared fields, did not:
    no bound is relaxed to inclusive, the search filters the index entries
    before the primary lookup, an index-only plan is allowed, and a
    condition on another field adds an assign above the primary-index
    search. These tests repeat the composite-bound, redundant-range,
    duplicate-key and IN-list cases in that setting, with values of mixed
    types, and add plans for IN lists next to an equality or a range.
    
    Ext-ref: MB-74315
    Generated-by: Claude Opus 5.5 <no...@anthropic.com>
    Change-Id: I5bfc7024931bad40832bcdc500bd422250f0fc0a
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/21920
    Reviewed-by: Murtadha Hubail <mh...@apache.org>
    Tested-by: Ali Alsuliman <al...@gmail.com>
---
 .../disjunctive-predicate-12.sqlpp                 | 55 ++++++++++++++++++++++
 .../disjunctive-predicate-13.sqlpp                 | 55 ++++++++++++++++++++++
 .../disjunctive-predicate-14.sqlpp                 | 39 +++++++++++++++
 .../disjunctive-predicate-15.sqlpp                 | 39 +++++++++++++++
 .../disjunctive-predicate-16.sqlpp                 | 39 +++++++++++++++
 .../disjunctive-predicate-17.sqlpp                 | 39 +++++++++++++++
 .../disjunctive-predicate-12.plan                  | 34 +++++++++++++
 .../disjunctive-predicate-13.plan                  | 32 +++++++++++++
 .../disjunctive-predicate-14.plan                  | 24 ++++++++++
 .../disjunctive-predicate-15.plan                  | 38 +++++++++++++++
 .../disjunctive-predicate-16.plan                  | 32 +++++++++++++
 .../disjunctive-predicate-17.plan                  | 42 +++++++++++++++++
 .../disjunctive-predicate-12.plan                  | 20 ++++++++
 .../disjunctive-predicate-13.plan                  | 18 +++++++
 .../disjunctive-predicate-14.plan                  | 24 ++++++++++
 .../disjunctive-predicate-15.plan                  | 24 ++++++++++
 .../disjunctive-predicate-16.plan                  | 24 ++++++++++
 .../disjunctive-predicate-17.plan                  | 24 ++++++++++
 ...dex-composite-prefix-range-untyped.01.ddl.sqlpp | 32 +++++++++++++
 ...-composite-prefix-range-untyped.02.update.sqlpp | 29 ++++++++++++
 ...x-composite-prefix-range-untyped.03.query.sqlpp | 22 +++++++++
 ...x-composite-prefix-range-untyped.04.query.sqlpp | 22 +++++++++
 ...x-composite-prefix-range-untyped.05.query.sqlpp | 22 +++++++++
 ...x-composite-prefix-range-untyped.06.query.sqlpp | 22 +++++++++
 ...x-composite-prefix-range-untyped.07.query.sqlpp | 22 +++++++++
 ...x-composite-prefix-range-untyped.08.query.sqlpp | 22 +++++++++
 ...x-composite-prefix-range-untyped.09.query.sqlpp | 22 +++++++++
 ...tree-index-redundant-range-untyped.01.ddl.sqlpp | 31 ++++++++++++
 ...e-index-redundant-range-untyped.02.update.sqlpp | 29 ++++++++++++
 ...ee-index-redundant-range-untyped.03.query.sqlpp | 22 +++++++++
 ...ee-index-redundant-range-untyped.04.query.sqlpp | 22 +++++++++
 ...ee-index-redundant-range-untyped.05.query.sqlpp | 22 +++++++++
 ...ee-index-redundant-range-untyped.06.query.sqlpp | 22 +++++++++
 ...ee-index-redundant-range-untyped.07.query.sqlpp | 22 +++++++++
 ...ee-index-redundant-range-untyped.08.query.sqlpp | 22 +++++++++
 .../in-list-duplicate-keys-untyped.01.ddl.sqlpp    | 33 +++++++++++++
 .../in-list-duplicate-keys-untyped.02.update.sqlpp | 29 ++++++++++++
 .../in-list-duplicate-keys-untyped.03.query.sqlpp  | 22 +++++++++
 .../in-list-duplicate-keys-untyped.04.query.sqlpp  | 22 +++++++++
 .../in-list-duplicate-keys-untyped.05.query.sqlpp  | 22 +++++++++
 .../in-list-duplicate-keys-untyped.06.query.sqlpp  | 22 +++++++++
 .../in-list-duplicate-keys-untyped.07.query.sqlpp  | 22 +++++++++
 .../in-list-duplicate-keys-untyped.08.query.sqlpp  | 22 +++++++++
 .../in-list-duplicate-keys-untyped.09.query.sqlpp  | 22 +++++++++
 .../in-list-duplicate-keys-untyped.10.query.sqlpp  | 22 +++++++++
 .../in-list-exact-search-untyped.01.ddl.sqlpp      | 32 +++++++++++++
 .../in-list-exact-search-untyped.02.update.sqlpp   | 29 ++++++++++++
 .../in-list-exact-search-untyped.03.query.sqlpp    | 22 +++++++++
 .../in-list-exact-search-untyped.04.query.sqlpp    | 22 +++++++++
 .../in-list-exact-search-untyped.05.query.sqlpp    | 22 +++++++++
 .../in-list-exact-search-untyped.06.query.sqlpp    | 22 +++++++++
 .../in-list-exact-search-untyped.07.query.sqlpp    | 22 +++++++++
 .../in-list-exact-search-untyped.08.query.sqlpp    | 22 +++++++++
 .../in-list-exact-search-untyped.09.query.sqlpp    | 22 +++++++++
 .../in-list-exact-search-untyped.10.query.sqlpp    | 22 +++++++++
 .../in-list-exact-search-untyped.11.query.sqlpp    | 22 +++++++++
 ...ree-index-composite-prefix-range-untyped.03.adm |  1 +
 ...ree-index-composite-prefix-range-untyped.04.adm |  1 +
 ...ree-index-composite-prefix-range-untyped.05.adm |  1 +
 ...ree-index-composite-prefix-range-untyped.06.adm |  1 +
 ...ree-index-composite-prefix-range-untyped.07.adm |  1 +
 ...ree-index-composite-prefix-range-untyped.08.adm |  1 +
 ...ree-index-composite-prefix-range-untyped.09.adm |  1 +
 .../btree-index-redundant-range-untyped.03.adm     |  1 +
 .../btree-index-redundant-range-untyped.04.adm     |  1 +
 .../btree-index-redundant-range-untyped.05.adm     |  1 +
 .../btree-index-redundant-range-untyped.06.adm     |  1 +
 .../btree-index-redundant-range-untyped.07.adm     |  1 +
 .../btree-index-redundant-range-untyped.08.adm     |  1 +
 .../in-list-duplicate-keys-untyped.03.adm          |  1 +
 .../in-list-duplicate-keys-untyped.04.adm          |  1 +
 .../in-list-duplicate-keys-untyped.05.adm          |  1 +
 .../in-list-duplicate-keys-untyped.06.adm          |  1 +
 .../in-list-duplicate-keys-untyped.07.adm          |  1 +
 .../in-list-duplicate-keys-untyped.08.adm          |  1 +
 .../in-list-duplicate-keys-untyped.09.adm          |  1 +
 .../in-list-duplicate-keys-untyped.10.adm          | 26 ++++++++++
 .../in-list-exact-search-untyped.03.adm            |  1 +
 .../in-list-exact-search-untyped.04.adm            |  1 +
 .../in-list-exact-search-untyped.05.adm            |  1 +
 .../in-list-exact-search-untyped.06.adm            |  1 +
 .../in-list-exact-search-untyped.07.adm            |  1 +
 .../in-list-exact-search-untyped.08.adm            |  1 +
 .../in-list-exact-search-untyped.09.adm            |  1 +
 .../in-list-exact-search-untyped.10.adm            | 26 ++++++++++
 .../in-list-exact-search-untyped.11.adm            |  1 +
 .../src/test/resources/runtimets/sqlpp_queries.xml | 20 ++++++++
 87 files changed, 1606 insertions(+)

diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-12.sqlpp b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-12.sqlpp
new file mode 100644
index 0000000000..9bf96b2584
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-12.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description: An equality on the key of an IN list is added to the list, so the search covers every value of the
+ *              list and the SELECT tests both conditions.
+ * Expected Result: Success
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+create type test.TestType as
+{
+  id : bigint,
+  a : bigint,
+  b : bigint,
+  c : bigint,
+  d : bigint
+};
+
+create type test.CompositeKeyType as
+{
+  k1 : bigint,
+  k2 : bigint,
+  v : bigint
+};
+
+create  dataset TestSet(TestType) primary key id;
+create  dataset CompositeKeySet(CompositeKeyType) primary key k1, k2;
+
+create  index idx_a  on TestSet (a) type btree;
+create  index idx_cd  on TestSet (c, d) type btree;
+
+select element x
+from  TestSet as x
+where x.a in [1, 2, 3] and x.a = 2
+;
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-13.sqlpp b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-13.sqlpp
new file mode 100644
index 0000000000..f4417e6a42
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-13.sqlpp
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description: A range on the key of an IN list is a wider search than the list, so the list drives the search and
+ *              the range is left to the SELECT.
+ * Expected Result: Success
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+create type test.TestType as
+{
+  id : bigint,
+  a : bigint,
+  b : bigint,
+  c : bigint,
+  d : bigint
+};
+
+create type test.CompositeKeyType as
+{
+  k1 : bigint,
+  k2 : bigint,
+  v : bigint
+};
+
+create  dataset TestSet(TestType) primary key id;
+create  dataset CompositeKeySet(CompositeKeyType) primary key k1, k2;
+
+create  index idx_a  on TestSet (a) type btree;
+create  index idx_cd  on TestSet (c, d) type btree;
+
+select element x
+from  TestSet as x
+where x.a in [1, 2, 3] and x.a > 1
+;
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-14.sqlpp b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-14.sqlpp
new file mode 100644
index 0000000000..034be00254
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-14.sqlpp
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description: An IN list on the second field of a primary key, after a range on the first, is left to the SELECT: a
+ *              search for each of its values would overlap the others.
+ * Expected Result: Success
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+create  dataset TestSet primary key (id: bigint);
+create  dataset CompositeKeySet primary key (k1: bigint, k2: bigint);
+
+create  index idx_a  on TestSet (a) type btree;
+create  index idx_cd  on TestSet (c, d) type btree;
+
+select value count(*)
+from  CompositeKeySet as x
+where x.k1 > 1 and x.k2 in [3, 4]
+;
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-15.sqlpp b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-15.sqlpp
new file mode 100644
index 0000000000..3e7b64a226
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-15.sqlpp
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description: An IN list on the second field of an untyped index, after a range on the first, is left to the
+ *              SELECT: a search for each of its values would overlap the others.
+ * Expected Result: Success
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+create  dataset TestSet primary key (id: bigint);
+create  dataset CompositeKeySet primary key (k1: bigint, k2: bigint);
+
+create  index idx_a  on TestSet (a) type btree;
+create  index idx_cd  on TestSet (c, d) type btree;
+
+select value sum(x.b)
+from  TestSet as x
+where x.c > 1 and x.d in [3, 4]
+;
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-16.sqlpp b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-16.sqlpp
new file mode 100644
index 0000000000..8e2a7d693d
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-16.sqlpp
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description: An index-only plan on an untyped index tests each entry against the value that found it rather than
+ *              the whole IN list.
+ * Expected Result: Success
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+create  dataset TestSet primary key (id: bigint);
+create  dataset CompositeKeySet primary key (k1: bigint, k2: bigint);
+
+create  index idx_a  on TestSet (a) type btree;
+create  index idx_cd  on TestSet (c, d) type btree;
+
+select value count(*)
+from  TestSet as x
+where x.a in [1, 2, 3]
+;
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-17.sqlpp b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-17.sqlpp
new file mode 100644
index 0000000000..28a3c5e819
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/btree-index-selection/disjunctive-predicate/disjunctive-predicate-17.sqlpp
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description: An IN list on the first field of an untyped composite index and a range on the second search the
+ *              range from an inclusive low bound.
+ * Expected Result: Success
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+create  dataset TestSet primary key (id: bigint);
+create  dataset CompositeKeySet primary key (k1: bigint, k2: bigint);
+
+create  index idx_a  on TestSet (a) type btree;
+create  index idx_cd  on TestSet (c, d) type btree;
+
+select value sum(x.b)
+from  TestSet as x
+where x.c in [1, 2] and x.d > 5
+;
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-12.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-12.plan
new file mode 100644
index 0000000000..3a52a4d950
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-12.plan
@@ -0,0 +1,34 @@
+distribute result [$$x]
+-- DISTRIBUTE_RESULT  |PARTITIONED|
+  exchange
+  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+    select (and(or(eq($$19, 1), $$29, eq($$19, 3)), $$29)) project: [$$x]
+    -- STREAM_SELECT  |PARTITIONED|
+      assign [$$29] <- [eq($$19, 2)]
+      -- ASSIGN  |PARTITIONED|
+        assign [$$19] <- [$$x.getField(1)]
+        -- ASSIGN  |PARTITIONED|
+          project ([$$x])
+          -- STREAM_PROJECT  |PARTITIONED|
+            exchange
+            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+              unnest-map [$$24, $$x] <- index-search("TestSet", 0, "Default", "test", "TestSet", true, false, 1, $$28, 1, $$28, true, true, true)
+              -- BTREE_SEARCH  |PARTITIONED|
+                exchange
+                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                  order (ASC, $$28)
+                  -- STABLE_SORT [$$28(ASC)]  |PARTITIONED|
+                    exchange
+                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                      project ([$$28])
+                      -- STREAM_PROJECT  |PARTITIONED|
+                        exchange
+                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                          unnest-map [$$27, $$28] <- index-search("idx_a", 0, "Default", "test", "TestSet", true, true, 1, $$26, 1, $$26, true, true, true)
+                          -- BTREE_SEARCH  |PARTITIONED|
+                            exchange
+                            -- BROADCAST_EXCHANGE  |PARTITIONED|
+                              unnest $$26 <- scan-collection(array: [ 1, 2, 3 ])
+                              -- UNNEST  |PARTITIONED|
+                                empty-tuple-source
+                                -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-13.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-13.plan
new file mode 100644
index 0000000000..7790f23248
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-13.plan
@@ -0,0 +1,32 @@
+distribute result [$$x]
+-- DISTRIBUTE_RESULT  |PARTITIONED|
+  exchange
+  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+    select (and(eq($$19, $$25), gt($$19, 1))) project: [$$x]
+    -- STREAM_SELECT  |PARTITIONED|
+      assign [$$19] <- [$$x.getField(1)]
+      -- ASSIGN  |PARTITIONED|
+        project ([$$25, $$x])
+        -- STREAM_PROJECT  |PARTITIONED|
+          exchange
+          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+            unnest-map [$$24, $$x] <- index-search("TestSet", 0, "Default", "test", "TestSet", true, false, 1, $$27, 1, $$27, true, true, true)
+            -- BTREE_SEARCH  |PARTITIONED|
+              exchange
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                order (ASC, $$27)
+                -- STABLE_SORT [$$27(ASC)]  |PARTITIONED|
+                  exchange
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    project ([$$25, $$27])
+                    -- STREAM_PROJECT  |PARTITIONED|
+                      exchange
+                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                        unnest-map [$$26, $$27] <- index-search("idx_a", 0, "Default", "test", "TestSet", true, true, 1, $$25, 1, $$25, true, true, true)
+                        -- BTREE_SEARCH  |PARTITIONED|
+                          exchange
+                          -- BROADCAST_EXCHANGE  |PARTITIONED|
+                            unnest $$25 <- scan-collection(array: [ 1, 2, 3 ])
+                            -- UNNEST  |PARTITIONED|
+                              empty-tuple-source
+                              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-14.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-14.plan
new file mode 100644
index 0000000000..7c364fb423
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-14.plan
@@ -0,0 +1,24 @@
+distribute result [$$49]
+-- DISTRIBUTE_RESULT  |UNPARTITIONED|
+  exchange
+  -- ONE_TO_ONE_EXCHANGE  |UNPARTITIONED|
+    aggregate [$$49] <- [agg-sql-sum($$51)]
+    -- AGGREGATE  |UNPARTITIONED|
+      exchange
+      -- RANDOM_MERGE_EXCHANGE  |PARTITIONED|
+        aggregate [$$51] <- [agg-sql-count(1)]
+        -- AGGREGATE  |PARTITIONED|
+          select (and(gt($$47, 1), or(eq($$48, 3), eq($$48, 4))))
+          -- STREAM_SELECT  |PARTITIONED|
+            project ([$$47, $$48])
+            -- STREAM_PROJECT  |PARTITIONED|
+              exchange
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                unnest-map [$$47, $$48, $$x] <- index-search("CompositeKeySet", 0, "Default", "test", "CompositeKeySet", false, false, 1, $$52, 0, true, true, true)
+                -- BTREE_SEARCH  |PARTITIONED|
+                  exchange
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    assign [$$52] <- [1]
+                    -- ASSIGN  |PARTITIONED|
+                      empty-tuple-source
+                      -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-15.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-15.plan
new file mode 100644
index 0000000000..660a2a62f3
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-15.plan
@@ -0,0 +1,38 @@
+distribute result [$$50]
+-- DISTRIBUTE_RESULT  |UNPARTITIONED|
+  exchange
+  -- ONE_TO_ONE_EXCHANGE  |UNPARTITIONED|
+    aggregate [$$50] <- [agg-global-sql-sum($$53)]
+    -- AGGREGATE  |UNPARTITIONED|
+      exchange
+      -- RANDOM_MERGE_EXCHANGE  |PARTITIONED|
+        aggregate [$$53] <- [agg-local-sql-sum($$46)]
+        -- AGGREGATE  |PARTITIONED|
+          select (and(gt($$x.getField("c"), 1), or(eq($$38, 3), eq($$38, 4)))) project: [$$46]
+          -- STREAM_SELECT  |PARTITIONED|
+            assign [$$38, $$46] <- [$$x.getField("d"), $$x.getField("b")]
+            -- ASSIGN  |PARTITIONED|
+              project ([$$x])
+              -- STREAM_PROJECT  |PARTITIONED|
+                exchange
+                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                  unnest-map [$$49, $$x] <- index-search("TestSet", 0, "Default", "test", "TestSet", false, false, 1, $$57, 1, $$57, true, true, true)
+                  -- BTREE_SEARCH  |PARTITIONED|
+                    exchange
+                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                      order (ASC, $$57)
+                      -- STABLE_SORT [$$57(ASC)]  |PARTITIONED|
+                        exchange
+                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                          select (and(gt($$55, 1), or(eq($$56, 3), eq($$56, 4)))) project: [$$57]
+                          -- STREAM_SELECT  |PARTITIONED|
+                            exchange
+                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                              unnest-map [$$55, $$56, $$57] <- index-search("idx_cd", 0, "Default", "test", "TestSet", false, false, 1, $$54, 0, true, true, true)
+                              -- BTREE_SEARCH  |PARTITIONED|
+                                exchange
+                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                  assign [$$54] <- [1]
+                                  -- ASSIGN  |PARTITIONED|
+                                    empty-tuple-source
+                                    -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-16.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-16.plan
new file mode 100644
index 0000000000..da253fb1da
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-16.plan
@@ -0,0 +1,32 @@
+distribute result [$$45]
+-- DISTRIBUTE_RESULT  |UNPARTITIONED|
+  exchange
+  -- ONE_TO_ONE_EXCHANGE  |UNPARTITIONED|
+    aggregate [$$45] <- [agg-sql-sum($$46)]
+    -- AGGREGATE  |UNPARTITIONED|
+      exchange
+      -- RANDOM_MERGE_EXCHANGE  |PARTITIONED|
+        aggregate [$$46] <- [agg-sql-count(1)]
+        -- AGGREGATE  |PARTITIONED|
+          exchange
+          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+            distinct ([$$49])
+            -- PRE_SORTED_DISTINCT_BY  |PARTITIONED|
+              exchange
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                order (ASC, $$49)
+                -- STABLE_SORT [$$49(ASC)]  |PARTITIONED|
+                  exchange
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    select (eq($$36, $$47)) project: [$$49]
+                    -- STREAM_SELECT  |PARTITIONED|
+                      exchange
+                      -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                        unnest-map [$$36, $$49] <- index-search("idx_a", 0, "Default", "test", "TestSet", true, true, 1, $$47, 1, $$47, true, true, true)
+                        -- BTREE_SEARCH  |PARTITIONED|
+                          exchange
+                          -- BROADCAST_EXCHANGE  |PARTITIONED|
+                            unnest $$47 <- scan-collection(array: [ 1, 2, 3 ])
+                            -- UNNEST  |PARTITIONED|
+                              empty-tuple-source
+                              -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-17.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-17.plan
new file mode 100644
index 0000000000..d6f753945e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results/btree-index-selection/disjunctive-predicate/disjunctive-predicate-17.plan
@@ -0,0 +1,42 @@
+distribute result [$$50]
+-- DISTRIBUTE_RESULT  |UNPARTITIONED|
+  exchange
+  -- ONE_TO_ONE_EXCHANGE  |UNPARTITIONED|
+    aggregate [$$50] <- [agg-global-sql-sum($$53)]
+    -- AGGREGATE  |UNPARTITIONED|
+      exchange
+      -- RANDOM_MERGE_EXCHANGE  |PARTITIONED|
+        aggregate [$$53] <- [agg-local-sql-sum($$46)]
+        -- AGGREGATE  |PARTITIONED|
+          select (and(gt($$x.getField("d"), 5), eq($$x.getField("c"), $$54))) project: [$$46]
+          -- STREAM_SELECT  |PARTITIONED|
+            assign [$$46] <- [$$x.getField("b")]
+            -- ASSIGN  |PARTITIONED|
+              project ([$$54, $$x])
+              -- STREAM_PROJECT  |PARTITIONED|
+                exchange
+                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                  unnest-map [$$49, $$x] <- index-search("TestSet", 0, "Default", "test", "TestSet", true, false, 1, $$58, 1, $$58, true, true, true)
+                  -- BTREE_SEARCH  |PARTITIONED|
+                    exchange
+                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                      order (ASC, $$58)
+                      -- STABLE_SORT [$$58(ASC)]  |PARTITIONED|
+                        exchange
+                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                          select (and(gt($$57, 5), eq($$56, $$54))) project: [$$54, $$58]
+                          -- STREAM_SELECT  |PARTITIONED|
+                            project ([$$54, $$56, $$57, $$58])
+                            -- STREAM_PROJECT  |PARTITIONED|
+                              exchange
+                              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                unnest-map [$$56, $$57, $$58] <- index-search("idx_cd", 0, "Default", "test", "TestSet", true, true, 2, $$54, $$55, 1, $$54, true, true, true)
+                                -- BTREE_SEARCH  |PARTITIONED|
+                                  exchange
+                                  -- BROADCAST_EXCHANGE  |PARTITIONED|
+                                    assign [$$55] <- [5]
+                                    -- ASSIGN  |PARTITIONED|
+                                      unnest $$54 <- scan-collection(array: [ 1, 2 ])
+                                      -- UNNEST  |PARTITIONED|
+                                        empty-tuple-source
+                                        -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/btree-index-selection/disjunctive-predicate/disjunctive-predicate-12.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/btree-index-selection/disjunctive-predicate/disjunctive-predicate-12.plan
new file mode 100644
index 0000000000..7c567f0c94
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/btree-index-selection/disjunctive-predicate/disjunctive-predicate-12.plan
@@ -0,0 +1,20 @@
+distribute result [$$x] [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+-- DISTRIBUTE_RESULT  |PARTITIONED|
+  exchange [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+    select (and(or(eq($$19, 1), $$26, eq($$19, 3)), $$26)) project: [$$x] [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+    -- STREAM_SELECT  |PARTITIONED|
+      assign [$$26] <- [eq($$19, 2)] [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+      -- ASSIGN  |PARTITIONED|
+        assign [$$19] <- [$$x.getField(1)] [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+        -- ASSIGN  |PARTITIONED|
+          project ([$$x]) [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+          -- STREAM_PROJECT  |PARTITIONED|
+            exchange [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+              data-scan []<-[$$24, $$x] <- test.TestSet [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+              -- DATASOURCE_SCAN  |PARTITIONED|
+                exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                  empty-tuple-source [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                  -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/btree-index-selection/disjunctive-predicate/disjunctive-predicate-13.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/btree-index-selection/disjunctive-predicate/disjunctive-predicate-13.plan
new file mode 100644
index 0000000000..bf3a3f461c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/btree-index-selection/disjunctive-predicate/disjunctive-predicate-13.plan
@@ -0,0 +1,18 @@
+distribute result [$$x] [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+-- DISTRIBUTE_RESULT  |PARTITIONED|
+  exchange [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+    select (and(or(eq($$19, 1), eq($$19, 2), eq($$19, 3)), gt($$19, 1))) project: [$$x] [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+    -- STREAM_SELECT  |PARTITIONED|
+      assign [$$19] <- [$$x.getField(1)] [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+      -- ASSIGN  |PARTITIONED|
+        project ([$$x]) [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+        -- STREAM_PROJECT  |PARTITIONED|
+          exchange [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+            data-scan []<-[$$24, $$x] <- test.TestSet [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+            -- DATASOURCE_SCAN  |PARTITIONED|
+              exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                empty-tuple-source [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/btree-index-selection/disjunctive-predicate/disjunctive-predicate-14.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/btree-index-selection/disjunctive-predicate/disjunctive-predicate-14.plan
new file mode 100644
index 0000000000..fc9776d891
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/btree-index-selection/disjunctive-predicate/disjunctive-predicate-14.plan
@@ -0,0 +1,24 @@
+distribute result [$$49] [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+-- DISTRIBUTE_RESULT  |UNPARTITIONED|
+  exchange [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+  -- ONE_TO_ONE_EXCHANGE  |UNPARTITIONED|
+    aggregate [$$49] <- [agg-sql-sum($$51)] [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+    -- AGGREGATE  |UNPARTITIONED|
+      exchange [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+      -- RANDOM_MERGE_EXCHANGE  |PARTITIONED|
+        aggregate [$$51] <- [agg-sql-count(1)] [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+        -- AGGREGATE  |PARTITIONED|
+          select (and(gt($$47, 1), or(eq($$48, 3), eq($$48, 4)))) [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+          -- STREAM_SELECT  |PARTITIONED|
+            project ([$$47, $$48]) [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+            -- STREAM_PROJECT  |PARTITIONED|
+              exchange [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                unnest-map [$$47, $$48, $$x] <- index-search("CompositeKeySet", 0, "Default", "test", "CompositeKeySet", false, false, 1, $$52, 0, true, true, true) [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+                -- BTREE_SEARCH  |PARTITIONED|
+                  exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                    assign [$$52] <- [1] [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                    -- ASSIGN  |PARTITIONED|
+                      empty-tuple-source [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                      -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/btree-index-selection/disjunctive-predicate/disjunctive-predicate-15.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/btree-index-selection/disjunctive-predicate/disjunctive-predicate-15.plan
new file mode 100644
index 0000000000..db967132a9
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/btree-index-selection/disjunctive-predicate/disjunctive-predicate-15.plan
@@ -0,0 +1,24 @@
+distribute result [$$50] [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+-- DISTRIBUTE_RESULT  |UNPARTITIONED|
+  exchange [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+  -- ONE_TO_ONE_EXCHANGE  |UNPARTITIONED|
+    aggregate [$$50] <- [agg-global-sql-sum($$53)] [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+    -- AGGREGATE  |UNPARTITIONED|
+      exchange [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+      -- RANDOM_MERGE_EXCHANGE  |PARTITIONED|
+        aggregate [$$53] <- [agg-local-sql-sum($$46)] [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+        -- AGGREGATE  |PARTITIONED|
+          select (and(gt($$x.getField("c"), 1), or(eq($$38, 3), eq($$38, 4)))) project: [$$46] [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+          -- STREAM_SELECT  |PARTITIONED|
+            assign [$$38, $$46] <- [$$x.getField("d"), $$x.getField("b")] [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+            -- ASSIGN  |PARTITIONED|
+              project ([$$x]) [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+              -- STREAM_PROJECT  |PARTITIONED|
+                exchange [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                  data-scan []<-[$$49, $$x] <- test.TestSet [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+                  -- DATASOURCE_SCAN  |PARTITIONED|
+                    exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                      empty-tuple-source [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                      -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/btree-index-selection/disjunctive-predicate/disjunctive-predicate-16.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/btree-index-selection/disjunctive-predicate/disjunctive-predicate-16.plan
new file mode 100644
index 0000000000..315be5865a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/btree-index-selection/disjunctive-predicate/disjunctive-predicate-16.plan
@@ -0,0 +1,24 @@
+distribute result [$$45] [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+-- DISTRIBUTE_RESULT  |UNPARTITIONED|
+  exchange [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+  -- ONE_TO_ONE_EXCHANGE  |UNPARTITIONED|
+    aggregate [$$45] <- [agg-sql-sum($$46)] [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+    -- AGGREGATE  |UNPARTITIONED|
+      exchange [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+      -- RANDOM_MERGE_EXCHANGE  |PARTITIONED|
+        aggregate [$$46] <- [agg-sql-count(1)] [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+        -- AGGREGATE  |PARTITIONED|
+          select (or(eq($$36, 1), eq($$36, 2), eq($$36, 3))) [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+          -- STREAM_SELECT  |PARTITIONED|
+            assign [$$36] <- [$$x.getField("a")] project: [$$36] [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+            -- ASSIGN  |PARTITIONED|
+              project ([$$x]) [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+              -- STREAM_PROJECT  |PARTITIONED|
+                exchange [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                  data-scan []<-[$$44, $$x] <- test.TestSet [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+                  -- DATASOURCE_SCAN  |PARTITIONED|
+                    exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                      empty-tuple-source [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                      -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/btree-index-selection/disjunctive-predicate/disjunctive-predicate-17.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/btree-index-selection/disjunctive-predicate/disjunctive-predicate-17.plan
new file mode 100644
index 0000000000..0e25ed3a71
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results_cbo/btree-index-selection/disjunctive-predicate/disjunctive-predicate-17.plan
@@ -0,0 +1,24 @@
+distribute result [$$50] [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+-- DISTRIBUTE_RESULT  |UNPARTITIONED|
+  exchange [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+  -- ONE_TO_ONE_EXCHANGE  |UNPARTITIONED|
+    aggregate [$$50] <- [agg-global-sql-sum($$53)] [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+    -- AGGREGATE  |UNPARTITIONED|
+      exchange [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+      -- RANDOM_MERGE_EXCHANGE  |PARTITIONED|
+        aggregate [$$53] <- [agg-local-sql-sum($$46)] [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+        -- AGGREGATE  |PARTITIONED|
+          select (and(gt($$x.getField("d"), 5), or(eq($$36, 1), eq($$36, 2)))) project: [$$46] [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+          -- STREAM_SELECT  |PARTITIONED|
+            assign [$$36, $$46] <- [$$x.getField("c"), $$x.getField("b")] [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+            -- ASSIGN  |PARTITIONED|
+              project ([$$x]) [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+              -- STREAM_PROJECT  |PARTITIONED|
+                exchange [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                  data-scan []<-[$$49, $$x] <- test.TestSet [cardinality: 1000000.0, doc-size: -1.0, op-cost: 0.0, total-cost: 499992.37]
+                  -- DATASOURCE_SCAN  |PARTITIONED|
+                    exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                      empty-tuple-source [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+                      -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.01.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.01.ddl.sqlpp
new file mode 100644
index 0000000000..6a8586b987
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.01.ddl.sqlpp
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description: equalities on a prefix of an untyped composite index and a one-sided range on the next key, on a
+ *              collection with no declared fields.
+ * Expected Result: Success
+ */
+
+DROP DATAVERSE test IF EXISTS;
+CREATE DATAVERSE test;
+USE test;
+
+CREATE DATASET ds PRIMARY KEY (id: bigint);
+CREATE DATASET ds2 PRIMARY KEY (k1: bigint, k2: bigint);
+CREATE INDEX idx_cd ON ds(c, d);
+CREATE INDEX idx_cde ON ds(c, d, e);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.02.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.02.update.sqlpp
new file mode 100644
index 0000000000..de75e1860d
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.02.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+INSERT INTO ds (SELECT VALUE {"id": i, "a": i % 50, "b": i % 7, "c": i % 5, "d": i % 11, "e": i % 4, "n": "s" || to_string(i % 20)}
+                FROM range(1, 600) i);
+INSERT INTO ds (SELECT VALUE {"id": i, "a": to_double(i % 50), "b": i % 7, "c": to_double(i % 5), "d": to_double(i % 11), "e": i % 4,
+                              "n": "s" || to_string(i % 20)} FROM range(601, 620) i);
+INSERT INTO ds (SELECT VALUE {"id": i, "a": to_string(i % 50), "b": i % 7, "c": to_string(i % 5), "d": to_string(i % 11), "e": i % 4,
+                              "n": i % 20} FROM range(621, 630) i);
+INSERT INTO ds (SELECT VALUE {"id": i, "b": i % 7} FROM range(631, 640) i);
+INSERT INTO ds2 (SELECT VALUE {"k1": i % 10, "k2": i DIV 10, "v": i} FROM range(1, 300) i);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.03.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.03.query.sqlpp
new file mode 100644
index 0000000000..e853174df9
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.03.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.c /* +use-index(idx_cd) */ = 1 AND d.d > 5;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.04.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.04.query.sqlpp
new file mode 100644
index 0000000000..164dc0edc4
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.04.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.c /* +use-index(idx_cd) */ = 1 AND d.d >= 5;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.05.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.05.query.sqlpp
new file mode 100644
index 0000000000..d6d8e5924c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.05.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.c /* +use-index(idx_cd) */ = 1 AND d.d < 5;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.06.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.06.query.sqlpp
new file mode 100644
index 0000000000..2c0efa22f1
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.06.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.c /* +use-index(idx_cd) */ = 1 AND d.d <= 5;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.07.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.07.query.sqlpp
new file mode 100644
index 0000000000..57ed6ef042
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.07.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.c /* +use-index(idx_cde) */ = 1 AND d.d = 2 AND d.e > 1;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.08.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.08.query.sqlpp
new file mode 100644
index 0000000000..d304147dd0
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.08.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.c /* +use-index(idx_cde) */ = 1 AND d.d = 2 AND d.e < 3;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.09.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.09.query.sqlpp
new file mode 100644
index 0000000000..ef16ff6c54
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.09.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.c /* +use-index(idx_cd) */ = 1 AND d.d > 5 AND (d.e = 1 OR d.e = 2);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.01.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.01.ddl.sqlpp
new file mode 100644
index 0000000000..78ff684a6d
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.01.ddl.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description: two range predicates on one key of an untyped index, on a collection with no declared fields, merged
+ *              into one bound: the tighter value with its own inclusiveness.
+ * Expected Result: Success
+ */
+
+DROP DATAVERSE test IF EXISTS;
+CREATE DATAVERSE test;
+USE test;
+
+CREATE DATASET ds PRIMARY KEY (id: bigint);
+CREATE DATASET ds2 PRIMARY KEY (k1: bigint, k2: bigint);
+CREATE INDEX idx_a ON ds(a);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.02.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.02.update.sqlpp
new file mode 100644
index 0000000000..de75e1860d
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.02.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+INSERT INTO ds (SELECT VALUE {"id": i, "a": i % 50, "b": i % 7, "c": i % 5, "d": i % 11, "e": i % 4, "n": "s" || to_string(i % 20)}
+                FROM range(1, 600) i);
+INSERT INTO ds (SELECT VALUE {"id": i, "a": to_double(i % 50), "b": i % 7, "c": to_double(i % 5), "d": to_double(i % 11), "e": i % 4,
+                              "n": "s" || to_string(i % 20)} FROM range(601, 620) i);
+INSERT INTO ds (SELECT VALUE {"id": i, "a": to_string(i % 50), "b": i % 7, "c": to_string(i % 5), "d": to_string(i % 11), "e": i % 4,
+                              "n": i % 20} FROM range(621, 630) i);
+INSERT INTO ds (SELECT VALUE {"id": i, "b": i % 7} FROM range(631, 640) i);
+INSERT INTO ds2 (SELECT VALUE {"k1": i % 10, "k2": i DIV 10, "v": i} FROM range(1, 300) i);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.03.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.03.query.sqlpp
new file mode 100644
index 0000000000..7a0561586c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.03.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.a > 5 AND d.a >= 7;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.04.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.04.query.sqlpp
new file mode 100644
index 0000000000..4574a350bb
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.04.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.a > 7 AND d.a >= 9;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.05.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.05.query.sqlpp
new file mode 100644
index 0000000000..5f9f25d267
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.05.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.a < 10 AND d.a <= 8;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.06.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.06.query.sqlpp
new file mode 100644
index 0000000000..9b2f6cb05c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.06.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.a < 7 AND d.a <= 5;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.07.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.07.query.sqlpp
new file mode 100644
index 0000000000..0488c9a3af
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.07.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.a >= 7 AND d.a > 7;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.08.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.08.query.sqlpp
new file mode 100644
index 0000000000..37ffaff600
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.08.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.a > 7 AND d.a >= 7;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.01.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.01.ddl.sqlpp
new file mode 100644
index 0000000000..4ec33b830f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.01.ddl.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description: IN lists and disjunctions that repeat a key, on untyped indexes and the primary key of a collection
+ *              with no declared fields; each record is returned once.
+ * Expected Result: Success
+ */
+
+DROP DATAVERSE test IF EXISTS;
+CREATE DATAVERSE test;
+USE test;
+
+CREATE DATASET ds PRIMARY KEY (id: bigint);
+CREATE DATASET ds2 PRIMARY KEY (k1: bigint, k2: bigint);
+CREATE INDEX idx_a ON ds(a);
+CREATE INDEX idx_n ON ds(n);
+CREATE INDEX idx_cd ON ds(c, d);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.02.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.02.update.sqlpp
new file mode 100644
index 0000000000..de75e1860d
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.02.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+INSERT INTO ds (SELECT VALUE {"id": i, "a": i % 50, "b": i % 7, "c": i % 5, "d": i % 11, "e": i % 4, "n": "s" || to_string(i % 20)}
+                FROM range(1, 600) i);
+INSERT INTO ds (SELECT VALUE {"id": i, "a": to_double(i % 50), "b": i % 7, "c": to_double(i % 5), "d": to_double(i % 11), "e": i % 4,
+                              "n": "s" || to_string(i % 20)} FROM range(601, 620) i);
+INSERT INTO ds (SELECT VALUE {"id": i, "a": to_string(i % 50), "b": i % 7, "c": to_string(i % 5), "d": to_string(i % 11), "e": i % 4,
+                              "n": i % 20} FROM range(621, 630) i);
+INSERT INTO ds (SELECT VALUE {"id": i, "b": i % 7} FROM range(631, 640) i);
+INSERT INTO ds2 (SELECT VALUE {"k1": i % 10, "k2": i DIV 10, "v": i} FROM range(1, 300) i);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.03.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.03.query.sqlpp
new file mode 100644
index 0000000000..6042088f2e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.03.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.id IN [1, 2, 3] AND d.id IN [2, 3, 4];
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.04.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.04.query.sqlpp
new file mode 100644
index 0000000000..44ebf92736
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.04.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.a IN [1, 1];
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.05.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.05.query.sqlpp
new file mode 100644
index 0000000000..e97b5c2e27
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.05.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.a = 1 OR 1 = d.a;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.06.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.06.query.sqlpp
new file mode 100644
index 0000000000..1ce0e5e963
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.06.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.a IN [1, 2, 1.0, 2.0];
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.07.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.07.query.sqlpp
new file mode 100644
index 0000000000..a387eafb72
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.07.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.a IN [1, 2] AND d.a IN [2, 3];
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.08.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.08.query.sqlpp
new file mode 100644
index 0000000000..e932c5afb3
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.08.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.n IN ["s1", "s1", "s2"];
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.09.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.09.query.sqlpp
new file mode 100644
index 0000000000..560895e16e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.09.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.c IN [1, 1] AND d.d IN [2, 2.0];
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.10.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.10.query.sqlpp
new file mode 100644
index 0000000000..32c217e042
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.10.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE d.id FROM ds d WHERE d.a IN [3, 1, 3, 1.0] ORDER BY d.id;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.01.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.01.ddl.sqlpp
new file mode 100644
index 0000000000..e181f6074c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.01.ddl.sqlpp
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Description: IN lists on the primary key and in index-only plans of untyped indexes, on a collection with no
+ *              declared fields, together with conditions on other fields.
+ * Expected Result: Success
+ */
+
+DROP DATAVERSE test IF EXISTS;
+CREATE DATAVERSE test;
+USE test;
+
+CREATE DATASET ds PRIMARY KEY (id: bigint);
+CREATE DATASET ds2 PRIMARY KEY (k1: bigint, k2: bigint);
+CREATE INDEX idx_a ON ds(a);
+CREATE INDEX idx_cd ON ds(c, d);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.02.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.02.update.sqlpp
new file mode 100644
index 0000000000..de75e1860d
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.02.update.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+INSERT INTO ds (SELECT VALUE {"id": i, "a": i % 50, "b": i % 7, "c": i % 5, "d": i % 11, "e": i % 4, "n": "s" || to_string(i % 20)}
+                FROM range(1, 600) i);
+INSERT INTO ds (SELECT VALUE {"id": i, "a": to_double(i % 50), "b": i % 7, "c": to_double(i % 5), "d": to_double(i % 11), "e": i % 4,
+                              "n": "s" || to_string(i % 20)} FROM range(601, 620) i);
+INSERT INTO ds (SELECT VALUE {"id": i, "a": to_string(i % 50), "b": i % 7, "c": to_string(i % 5), "d": to_string(i % 11), "e": i % 4,
+                              "n": i % 20} FROM range(621, 630) i);
+INSERT INTO ds (SELECT VALUE {"id": i, "b": i % 7} FROM range(631, 640) i);
+INSERT INTO ds2 (SELECT VALUE {"k1": i % 10, "k2": i DIV 10, "v": i} FROM range(1, 300) i);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.03.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.03.query.sqlpp
new file mode 100644
index 0000000000..cbdb71a05c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.03.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.id IN [1, 2, 3, 4, 5, 6, 7, 8] AND d.b = 1;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.04.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.04.query.sqlpp
new file mode 100644
index 0000000000..6da90fedeb
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.04.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.id IN [1, 2, 3, 4, 5, 6, 7, 8] AND d.id > 1 AND d.b = 1;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.05.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.05.query.sqlpp
new file mode 100644
index 0000000000..eb8b1024a2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.05.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds2 d WHERE d.k1 IN [1, 2] AND d.k2 > 25 AND d.v > 0;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.06.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.06.query.sqlpp
new file mode 100644
index 0000000000..c57de08404
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.06.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds2 d WHERE d.k1 > 1 AND d.k2 IN [3, 4] AND d.v > 0;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.07.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.07.query.sqlpp
new file mode 100644
index 0000000000..c684570fd0
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.07.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds2 d WHERE d.k1 > 1 AND d.k2 IN [3, 4];
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.08.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.08.query.sqlpp
new file mode 100644
index 0000000000..18264a9285
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.08.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.c > 1 AND d.d IN [3, 4];
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.09.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.09.query.sqlpp
new file mode 100644
index 0000000000..44fbb3f9db
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.09.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.a IN [1, 2, 3];
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.10.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.10.query.sqlpp
new file mode 100644
index 0000000000..81f9418997
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.10.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE d.a FROM ds d WHERE d.a IN [1, 2] ORDER BY d.a, d.id;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.11.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.11.query.sqlpp
new file mode 100644
index 0000000000..8e446cd257
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.11.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+USE test;
+
+SELECT VALUE COUNT(*) FROM ds d WHERE d.c IN [1, 2] AND d.d = 5;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.03.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.03.adm
new file mode 100644
index 0000000000..f6b91e0e1f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.03.adm
@@ -0,0 +1 @@
+56
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.04.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.04.adm
new file mode 100644
index 0000000000..3fdcd7c44c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.04.adm
@@ -0,0 +1 @@
+67
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.05.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.05.adm
new file mode 100644
index 0000000000..e1617e842a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.05.adm
@@ -0,0 +1 @@
+57
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.06.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.06.adm
new file mode 100644
index 0000000000..38b10c1b2b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.06.adm
@@ -0,0 +1 @@
+68
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.07.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.07.adm
new file mode 100644
index 0000000000..7ed6ff82de
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.07.adm
@@ -0,0 +1 @@
+5
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.08.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.08.adm
new file mode 100644
index 0000000000..ec635144f6
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.08.adm
@@ -0,0 +1 @@
+9
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.09.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.09.adm
new file mode 100644
index 0000000000..9902f17848
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-composite-prefix-range-untyped/btree-index-composite-prefix-range-untyped.09.adm
@@ -0,0 +1 @@
+28
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.03.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.03.adm
new file mode 100644
index 0000000000..137b8338f2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.03.adm
@@ -0,0 +1 @@
+530
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.04.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.04.adm
new file mode 100644
index 0000000000..3091e8eea2
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.04.adm
@@ -0,0 +1 @@
+504
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.05.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.05.adm
new file mode 100644
index 0000000000..4699eb3cc9
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.05.adm
@@ -0,0 +1 @@
+116
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.06.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.06.adm
new file mode 100644
index 0000000000..987e7ca9a7
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.06.adm
@@ -0,0 +1 @@
+77
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.07.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.07.adm
new file mode 100644
index 0000000000..ac953cd01a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.07.adm
@@ -0,0 +1 @@
+517
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.08.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.08.adm
new file mode 100644
index 0000000000..ac953cd01a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/btree-index-redundant-range-untyped/btree-index-redundant-range-untyped.08.adm
@@ -0,0 +1 @@
+517
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.03.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.03.adm
new file mode 100644
index 0000000000..0cfbf08886
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.03.adm
@@ -0,0 +1 @@
+2
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.04.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.04.adm
new file mode 100644
index 0000000000..b1bd38b62a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.04.adm
@@ -0,0 +1 @@
+13
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.05.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.05.adm
new file mode 100644
index 0000000000..b1bd38b62a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.05.adm
@@ -0,0 +1 @@
+13
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.06.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.06.adm
new file mode 100644
index 0000000000..6f4247a625
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.06.adm
@@ -0,0 +1 @@
+26
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.07.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.07.adm
new file mode 100644
index 0000000000..b1bd38b62a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.07.adm
@@ -0,0 +1 @@
+13
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.08.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.08.adm
new file mode 100644
index 0000000000..a8fa06e1be
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.08.adm
@@ -0,0 +1 @@
+62
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.09.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.09.adm
new file mode 100644
index 0000000000..b4de394767
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.09.adm
@@ -0,0 +1 @@
+11
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.10.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.10.adm
new file mode 100644
index 0000000000..a91396562c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-duplicate-keys-untyped/in-list-duplicate-keys-untyped.10.adm
@@ -0,0 +1,26 @@
+1
+3
+51
+53
+101
+103
+151
+153
+201
+203
+251
+253
+301
+303
+351
+353
+401
+403
+451
+453
+501
+503
+551
+553
+601
+603
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.03.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.03.adm
new file mode 100644
index 0000000000..0cfbf08886
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.03.adm
@@ -0,0 +1 @@
+2
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.04.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.04.adm
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.04.adm
@@ -0,0 +1 @@
+1
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.05.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.05.adm
new file mode 100644
index 0000000000..45a4fb75db
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.05.adm
@@ -0,0 +1 @@
+8
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.06.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.06.adm
new file mode 100644
index 0000000000..b6a7d89c68
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.06.adm
@@ -0,0 +1 @@
+16
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.07.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.07.adm
new file mode 100644
index 0000000000..b6a7d89c68
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.07.adm
@@ -0,0 +1 @@
+16
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.08.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.08.adm
new file mode 100644
index 0000000000..b5489e5e51
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.08.adm
@@ -0,0 +1 @@
+69
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.09.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.09.adm
new file mode 100644
index 0000000000..a2720097dc
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.09.adm
@@ -0,0 +1 @@
+39
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.10.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.10.adm
new file mode 100644
index 0000000000..74f05ea9eb
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.10.adm
@@ -0,0 +1,26 @@
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1
+1.0
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2
+2.0
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.11.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.11.adm
new file mode 100644
index 0000000000..2bd5a0a98a
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/in-list-exact-search-untyped/in-list-exact-search-untyped.11.adm
@@ -0,0 +1 @@
+22
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml b/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
index 666be3a4ae..2f1e920356 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
@@ -6490,6 +6490,11 @@
         <output-dir compare="Text">btree-index-composite-prefix-range</output-dir>
       </compilation-unit>
     </test-case>
+    <test-case FilePath="index-selection">
+      <compilation-unit name="btree-index-composite-prefix-range-untyped">
+        <output-dir compare="Text">btree-index-composite-prefix-range-untyped</output-dir>
+      </compilation-unit>
+    </test-case>
     <test-case FilePath="index-selection">
       <compilation-unit name="secondary-index-or-in-01">
         <output-dir compare="Text">secondary-index-or-in-01</output-dir>
@@ -6758,11 +6763,21 @@
         <output-dir compare="Text">in-list-duplicate-keys</output-dir>
       </compilation-unit>
     </test-case>
+    <test-case FilePath="index-selection">
+      <compilation-unit name="in-list-duplicate-keys-untyped">
+        <output-dir compare="Text">in-list-duplicate-keys-untyped</output-dir>
+      </compilation-unit>
+    </test-case>
     <test-case FilePath="index-selection">
       <compilation-unit name="in-list-exact-search">
         <output-dir compare="Text">in-list-exact-search</output-dir>
       </compilation-unit>
     </test-case>
+    <test-case FilePath="index-selection">
+      <compilation-unit name="in-list-exact-search-untyped">
+        <output-dir compare="Text">in-list-exact-search-untyped</output-dir>
+      </compilation-unit>
+    </test-case>
     <test-case FilePath="index-selection">
       <compilation-unit name="inverted-index-ngram-edit-distance-with-two-ngram-index">
         <output-dir compare="Text">inverted-index-ngram-edit-distance-with-two-ngram-index</output-dir>
@@ -6825,6 +6840,11 @@
         <output-dir compare="Text">btree-index-redundant-range</output-dir>
       </compilation-unit>
     </test-case>
+    <test-case FilePath="index-selection">
+      <compilation-unit name="btree-index-redundant-range-untyped">
+        <output-dir compare="Text">btree-index-redundant-range-untyped</output-dir>
+      </compilation-unit>
+    </test-case>
     <test-case FilePath="index-selection">
       <compilation-unit name="heterogeneous-index-complex-types">
         <output-dir compare="Text">heterogeneous-index-complex-types</output-dir>