summaryrefslogtreecommitdiff
path: root/jstests/core
diff options
context:
space:
mode:
authorDianna Hohensee <dianna.hohensee@mongodb.com>2022-12-21 17:27:52 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-12-21 17:58:18 +0000
commit42667e3c762bd83d700696ec4635e41fb8471c0f (patch)
treece261b77ca80040883658b0e00afa14f515a28c1 /jstests/core
parent96eca5891fe7e7fa3cdc30950530249e2c109d31 (diff)
downloadmongo-42667e3c762bd83d700696ec4635e41fb8471c0f.tar.gz
SERVER-68377 Skip creating a dense column cursor during a column scan when an _id column cursor (also dense) is present
Diffstat (limited to 'jstests/core')
-rw-r--r--jstests/core/columnstore_index_correctness.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/jstests/core/columnstore_index_correctness.js b/jstests/core/columnstore_index_correctness.js
index 3ab0dd5b11a..1466324c98c 100644
--- a/jstests/core/columnstore_index_correctness.js
+++ b/jstests/core/columnstore_index_correctness.js
@@ -105,6 +105,41 @@ const coll = db.columnstore_index_correctness;
}
})();
+(function testColumnScanFindsAllDocumentsUsingDenseColumn() {
+ // Check that column scan projections without filters will return all the documents, leveraging
+ // dense columns internally regardless of whether _id is included or not. Internally, the dense
+ // RowId Column will be scanned if the dense _id field is not included in the query. Scanning a
+ // dense field column, which has a value present for every document in the collection, is
+ // necessary to find documents missing all projected fields -- in the following queries
+ // ultimately returning empty documents for such documents, rather than not at all.
+
+ // Store documents where 'x' and 'y' fields are missing in some documents but present in other
+ // documents. This should cause the dense _id or internal RowId columns to be used to identify
+ // null field values.
+ const docs = [
+ {_id: 0, x: 1, y: "fee"},
+ {_id: 1},
+ {_id: 2, x: 1},
+ {_id: 3, y: "fii"},
+ {_id: 4, x: 1, y: "foo"},
+ {_id: 5},
+ {_id: 6, x: 1}
+ ];
+ coll.drop();
+ assert.commandWorked(coll.insertMany(docs));
+ assert.commandWorked(coll.createIndex({"$**": "columnstore"}));
+
+ const findDocsWithoutID = coll.find({}, {_id: 0, "x": 1, "y": 1}).toArray();
+ assert.eq(findDocsWithoutID.length,
+ docs.length,
+ `Unexpected number of documents: ${tojson(findDocsWithoutID)}`);
+
+ const findDocsWithID = coll.find({}, {_id: 1, "x": 1, "y": 1}).toArray();
+ assert.eq(findDocsWithID.length,
+ docs.length,
+ `Unexpected number of documents: ${tojson(findDocsWithID)}`);
+})();
+
// Multiple tests in this file use the same dataset. Intentionally not using _id as the unique
// identifier, to avoid getting IDHACK plans when we query by it.
const docs = [