diff --git a/src/mongo/db/pipeline/document_source_sort.cpp b/src/mongo/db/pipeline/document_source_sort.cpp
|
index fe32168c17..4d9fde0afe 100644
|
--- a/src/mongo/db/pipeline/document_source_sort.cpp
|
+++ b/src/mongo/db/pipeline/document_source_sort.cpp
|
@@ -27,6 +27,8 @@
|
* it in the license file.
|
*/
|
|
+#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kQuery
|
+
|
#include "mongo/platform/basic.h"
|
|
#include "mongo/db/pipeline/document_source_sort.h"
|
@@ -41,6 +43,7 @@
|
#include "mongo/db/query/collation/collation_index_key.h"
|
#include "mongo/platform/overflow_arithmetic.h"
|
#include "mongo/s/query/document_source_merge_cursors.h"
|
+#include "mongo/util/log.h"
|
|
namespace mongo {
|
|
@@ -358,6 +361,11 @@ std::pair<Value, Document> DocumentSourceSort::extractSortKey(Document&& doc) co
|
|
auto fastKey = extractKeyFast(doc);
|
if (fastKey.isOK()) {
|
+ log() << "@@@ (fast) fast sort key for " << doc << " is " << fastKey.getValue();
|
+ auto tempInMemorySortKey =
|
+ deserializeSortKey(_sortExecutor->sortPattern().size(), extractKeyWithArray(doc));
|
+ log() << "@@@ (fast) slow sort key for " << doc << " is " << tempInMemorySortKey;
|
+
|
inMemorySortKey = std::move(fastKey.getValue());
|
if (pExpCtx->needsMerge) {
|
serializedSortKey =
|
@@ -368,9 +376,12 @@ std::pair<Value, Document> DocumentSourceSort::extractSortKey(Document&& doc) co
|
// sort key, which is an object with empty field names. We then need to convert this BSON
|
// representation into the corresponding array of keys as a Value. BSONObj {'': 1, '': [2,
|
// 3]} becomes Value [1, [2, 3]].
|
+ log() << "@@@ (slow) fast sort key for " << doc
|
+ << " couldn't be extracted: " << fastKey.getStatus();
|
serializedSortKey = extractKeyWithArray(doc);
|
inMemorySortKey =
|
deserializeSortKey(_sortExecutor->sortPattern().size(), *serializedSortKey);
|
+ log() << "@@@ (slow) slow sort key for " << doc << " is " << inMemorySortKey;
|
}
|
|
MutableDocument toBeSorted(std::move(doc));
|