diff options
author | Dan Larkin-York <dan.larkin-york@mongodb.com> | 2022-04-22 00:02:29 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-04-22 00:42:29 +0000 |
commit | a0f786dca14008612eadeb7d37d30cfd7690f7ed (patch) | |
tree | 50b1a6c93462f4e59cd5ab137a5ca97a8da0b5cb /jstests | |
parent | 46be98147821353da22d0e647ff06fdb7e6fa5c7 (diff) | |
download | mongo-a0f786dca14008612eadeb7d37d30cfd7690f7ed.tar.gz |
SERVER-65881 Support sort-limit optimization with bounded sort stage
Diffstat (limited to 'jstests')
3 files changed, 21 insertions, 26 deletions
diff --git a/jstests/core/timeseries/timeseries_internal_bounded_sort.js b/jstests/core/timeseries/timeseries_internal_bounded_sort.js index 67cdc4c1c31..30e58b7d42e 100644 --- a/jstests/core/timeseries/timeseries_internal_bounded_sort.js +++ b/jstests/core/timeseries/timeseries_internal_bounded_sort.js @@ -136,10 +136,10 @@ function runTest(ascending) { $_internalBoundedSort: { sortKey: {t: ascending ? 1 : -1}, bound: ascending ? {base: "min"} - : {base: "min", offset: bucketMaxSpanSeconds} + : {base: "min", offset: bucketMaxSpanSeconds}, + limit: 100 } }, - {$limit: 100}, ]) .toArray(); assertSorted(optFromMin, ascending); @@ -155,10 +155,10 @@ function runTest(ascending) { $_internalBoundedSort: { sortKey: {t: ascending ? 1 : -1}, bound: ascending ? {base: "max", offset: -bucketMaxSpanSeconds} - : {base: "max"} + : {base: "max"}, + limit: 100 } - }, - {$limit: 100}, + } ]) .toArray(); assertSorted(optFromMax, ascending); diff --git a/jstests/core/timeseries/timeseries_internal_bounded_sort_compound.js b/jstests/core/timeseries/timeseries_internal_bounded_sort_compound.js index 9f290b1774b..2e73a808d85 100644 --- a/jstests/core/timeseries/timeseries_internal_bounded_sort_compound.js +++ b/jstests/core/timeseries/timeseries_internal_bounded_sort_compound.js @@ -174,10 +174,10 @@ function runTest(sortSpec) { $_internalBoundedSort: { sortKey: sortSpec, bound: sortSpec.t > 0 ? {base: "min"} - : {base: "min", offset: bucketMaxSpanSeconds} + : {base: "min", offset: bucketMaxSpanSeconds}, + limit: 100 } - }, - {$limit: 100}, + } ]; const optFromMin = buckets.aggregate(optFromMinQuery).toArray(); assertSorted(optFromMin, sortSpec); @@ -191,10 +191,10 @@ function runTest(sortSpec) { $_internalBoundedSort: { sortKey: sortSpec, bound: sortSpec.t > 0 ? {base: "max", offset: -bucketMaxSpanSeconds} - : {base: "max"} + : {base: "max"}, + limit: 100 } - }, - {$limit: 100}, + } ]; const optFromMax = buckets.aggregate(optFromMaxQuery).toArray(); assertSorted(optFromMax, sortSpec); diff --git a/jstests/noPassthrough/timeseries_internal_bounded_sort_spilling.js b/jstests/noPassthrough/timeseries_internal_bounded_sort_spilling.js index bd5d7e9bcca..0014dc64d95 100644 --- a/jstests/noPassthrough/timeseries_internal_bounded_sort_spilling.js +++ b/jstests/noPassthrough/timeseries_internal_bounded_sort_spilling.js @@ -158,21 +158,16 @@ function assertSorted(result) { assertSorted(naive); assert.eq(100, naive.length); - const opt = buckets - .aggregate( - [ - {$sort: {'control.min.t': 1}}, - unpackStage, - { - $_internalBoundedSort: { - sortKey: {t: 1}, - bound: {base: "min"}, - } - }, - {$limit: 100}, - ], - {allowDiskUse: true}) - .toArray(); + const opt = + buckets + .aggregate( + [ + {$sort: {'control.min.t': 1}}, + unpackStage, + {$_internalBoundedSort: {sortKey: {t: 1}, bound: {base: "min"}, limit: 100}} + ], + {allowDiskUse: true}) + .toArray(); assertSorted(opt); assert.eq(100, opt.length); |