Hi
I have an aggregate pipeline that is taking too long to run, and when I run the aggregate with explain there is not information about Index usage or winningPlan, why is that?
I have tried to search for this, but I can’t find any information.
Isn’t this information available for an aggregate?
I have watched a lot of videos about find and explain, but haven’t found any one that brings up this situation.
This is my aggregate pipelines:
db.getCollection('songs').explain('executionStats').aggregate(
[
{
"$search":{
"index": 'lyricsSearch',
"phrase":{
"query": "love",
"path" :'lyrics.textLine',
},
"highlight":{
"path":'lyrics.textLine'
}
},
},
{
$match:{
languages: {$in:['en', 'sv']}
}
},
{
$sort : {
score:-1,
spotifyPopularity:-1,
}
},
{
$limit:200
},
{
$project: {
_id: 1,
title: 1,
artist:1,
lyrics: 1,
posterImage: 1,
video:1,
youtubeLink:1,
spotifyId:1,
spotifyPopularity:1,
score: { $meta: 'searchScore' },
highlight: { $meta: 'searchHighlights' }
}
},
]
)
And here is the explain result:
{
"explainVersion": "1",
"stages": [
{
"$_internalSearchMongotRemote": {
"mongotQuery": {
"index": "lyricsSearch",
"phrase": {
"query": "love",
"path": "lyrics.textLine"
},
"highlight": {
"path": "lyrics.textLine"
}
},
"explain": {
"type": "TermQuery",
"args": {
"path": "lyrics.textLine",
"value": "love"
},
"stats": {
"context": {
"nanosElapsed": 7861461,
"invocationCounts": {
"createWeight": 1,
"createScorer": 8
}
},
"match": {
"nanosElapsed": 1120063,
"invocationCounts": {
"nextDoc": 11513
}
},
"score": {
"nanosElapsed": 3423048,
"invocationCounts": {
"setMinCompetitiveScore": 220,
"score": 11509
}
}
}
}
},
"nReturned": 0,
"executionTimeMillisEstimate": 18
},
{
"$_internalSearchIdLookup": {},
"nReturned": 0,
"executionTimeMillisEstimate": 18
},
{
"$match": {
"languages": {
"$in": [
"en",
"sv"
]
}
},
"nReturned": 0,
"executionTimeMillisEstimate": 18
},
{
"$sort": {
"sortKey": {
"score": -1,
"spotifyPopularity": -1
},
"limit": 200
},
"totalDataSizeSortedBytesEstimate": 0,
"usedDisk": false,
"spills": 0,
"nReturned": 0,
"executionTimeMillisEstimate": 18
},
{
"$project": {
"_id": true,
"artist": true,
"youtubeLink": true,
"lyrics": true,
"spotifyId": true,
"video": true,
"title": true,
"posterImage": true,
"spotifyPopularity": true,
"score": {
"$meta": "searchScore"
},
"highlight": {
"$meta": "searchHighlights"
}
},
"nReturned": 0,
"executionTimeMillisEstimate": 18
}
],
"serverInfo": {
"host": "atlas-yeynqc-shard-00-01.ywrjg.mongodb.net",
"port": 27017,
"version": "6.0.10",
"gitVersion": "8e4b5670df9b9fe814e57cb5f3f8ee9407237b5a"
},
"serverParameters": {
"internalQueryFacetBufferSizeBytes": 104857600,
"internalQueryFacetMaxOutputDocSizeBytes": 104857600,
"internalLookupStageIntermediateDocumentMaxSizeBytes": 104857600,
"internalDocumentSourceGroupMaxMemoryBytes": 104857600,
"internalQueryMaxBlockingSortMemoryUsageBytes": 104857600,
"internalQueryProhibitBlockingMergeOnMongoS": 0,
"internalQueryMaxAddToSetBytes": 104857600,
"internalDocumentSourceSetWindowFieldsMaxMemoryBytes": 104857600
},
"command": {
"aggregate": "songs",
"pipeline": [
{
"$search": {
"index": "lyricsSearch",
"phrase": {
"query": "love",
"path": "lyrics.textLine"
},
"highlight": {
"path": "lyrics.textLine"
}
}
},
{
"$match": {
"languages": {
"$in": [
"en",
"sv"
]
}
}
},
{
"$sort": {
"score": -1,
"spotifyPopularity": -1
}
},
{
"$limit": 200
},
{
"$project": {
"_id": 1,
"title": 1,
"artist": 1,
"lyrics": 1,
"posterImage": 1,
"video": 1,
"youtubeLink": 1,
"spotifyId": 1,
"spotifyPopularity": 1,
"score": {
"$meta": "searchScore"
},
"highlight": {
"$meta": "searchHighlights"
}
}
}
],
"cursor": {},
"$db": "songsay"
},
"ok": 1,
"$clusterTime": {
"clusterTime": {
"$timestamp": {
"t": 1695038389,
"i": 3
}
},
"signature": {
"hash": {
"$binary": {
"base64": "KaIV8c6iWtbkQ0D+QMnZ9sl1ef4=",
"subType": "00"
}
},
"keyId": 7243340663985537000
}
},
"operationTime": {
"$timestamp": {
"t": 1695038389,
"i": 3
}
}
}
I would be very grateful if someone could point me in the right direction