Skip to content

WIP Add benchmarks for single predicate collscan shortcut #143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions testcases/simple_query.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,90 @@ if (typeof(tests) !== "object") {
op: {op: "find", query: {nonexistent: 5}}
});

/**
* Setup: Create a large collection of large documents.
*
* Test: Query for a document that doesn't exist. Scans all documents using a collection scan
* and returns no documents.
*/
for (const [n, title] of [[10000, "10K"], [100000, "100K"]]) {
addQueryTestCase({
name: "NoMatchLarge" + title,
tags: ["regression"],
nDocs: n,
docs: largeDoc,
op: {op: "find", query: {nonexistent: 5}}
});
}

/**
* Setup: Create a collection of documents with ObjectID '_id' and 'a' fields.
*
* Test: Query with an equality predicate matches returns every other document. Scans all documents using a collection scan.
*/
for (const [n, title] of [[100, "100"], [10000, "10K"], [100000, "100K"]]) {
addQueryTestCase({
name: "HalfMatchEqInt" + title,
tags: ["regression"],
nDocs: n,
docs: function(i) {
return {a: i % 2};
},
op: {op: "find", query: {a: 0}}
});
}

/**
* Setup: Create a collection of documents with ObjectID '_id' and 'a' fields.
*
* Test: Query with a $lt predicate that matches every other document. Scans all documents using a collection scan.
*/
for (const [n, title] of [[100, "100"], [10000, "10K"], [100000, "100K"]]) {
addQueryTestCase({
name: "HalfMatchLtInt" + title,
tags: ["regression"],
nDocs: n,
docs: function(i) {
return {a: i % 2};
},
op: {op: "find", query: {a: {$lt: 1}}}
});
}

/**
* Setup: Create a collection of documents with ObjectID '_id' and 'a' fields.
*
* Test: Query with an equality predicate that matches every other document. Scans all documents using a collection scan.
*/
for (const [n, title] of [[100, "100"], [10000, "10K"], [100000, "100K"]]) {
addQueryTestCase({
name: "HalfMatchEqNaN" + title,
tags: ["regression"],
nDocs: n,
docs: function(i) {
return {a: (i % 2 == 0 ? NaN : 0)};
},
op: {op: "find", query: {a: NaN}}
});
}

/**
* Setup: Create a collection of documents with ObjectID '_id' and 'a' fields.
*
* Test: Query with a $lt predicate that matches every other document. Scans all documents using a collection scan.
*/
for (const [n, title] of [[100, "100"], [10000, "10K"], [100000, "100K"]]) {
addQueryTestCase({
name: "HalfMatchLteNaN" + title,
tags: ["regression"],
nDocs: n,
docs: function(i) {
return {a: (i % 2 == 0 ? NaN : 0)};
},
op: {op: "find", query: {a: {$lte: NaN}}}
});
}

/**
* Setup: Create a collection of documents with only an integer _id field.
*
Expand Down