Recuperar o plano de query e as estatísticas de execução
Nesta página
A query do Atlas Search retorna informações sobre o $search
plano de query e a estatística de execução quando a query é executada com o explain
método ativado. Quando você executa uma query explain
com, o Atlas Search retorna um documentoBSON contendo estatísticas e metadados que descrevem como a query foi executada internamente no Lucene.
Sintaxe
db.<myCollection>.explain("<verbosity>").aggregate([ { $search: { "<operator>": { "<operator-options>" } } } ])
Detalhamento
O modo Verbosidade controla o comportamento do explain
e a quantidade de informações retornadas. O valor pode ser um dos seguintes:
Informações sobre o plano de query , incluindo os campos | |
Informações sobre o plano de query , incluindo os campos | |
queryPlanner (padrão) | Informações sobre o plano de query. Não inclui os campos |
Explicação de resultados
Os explain
resultados é um documento BSON com os seguintes campos.
Opção | Tipo | necessidade | Propósito |
---|---|---|---|
| documento | Opcional | Descreve as estatísticas de execução do coletor. |
| documento | Opcional | Detalhes sobre a execução do destaque para a query. Isso será retornado somente se você especificar realce na query. |
| matriz de documentos | Opcional | Contém detalhes de partição por índice. Isso só é retornado se você configurou duas ou mais partições de índice. |
| documento | Opcional | Contém metadados úteis. |
| documento | Opcional | Descreve as estatísticas de execução da query. Isto não está presente no nível superior para |
| documento | Opcional | Detalhes relacionados à recuperação de dados por documento do Lucene após a execução da query. Isto não é devolvido para o modo de verbosidade |
| documento | Opcional | Detalha o uso do recurso da query quando ela foi executada. Isto não é devolvido para o modo de verbosidade |
collectors
O collectors
é um documento BSON com os seguintes campos:
Opção | Tipo | necessidade | Propósito |
---|---|---|---|
| documento | Obrigatório | Estatísticas de todos os coletores da query. As estatísticas representam o valor máximo em todos os coletores usados na query e são uma soma de todos os subcoletores. As estatísticas de tempo são somadas para refletir o tempo total gasto em todos os coletores para toda a query. Para saber mais, |
| documento | Opcional | Detalhamento da query que especifica o faceta. Para saber mais, |
| documento | Opcional | Detalhamento da query que especifica a classificação. Para saber mais, |
allCollectorStats
O allCollectorStats
é um documento BSON que descreve as estatísticas de coletor de todos os coletores especificados na query, incluindo facet
sort
e. Contém as seguintes chaves:
| Rastreia a duração e o número de resultados coletados pelo coletor. |
| Estatísticas que acompanham a duração total e o número de vezes que um |
| Estatísticas que acompanham a duração total e o número de vezes que um marcador foi definido no coletor. |
facet
O facet
é um documento BSON que detalha a estatística de query e execução quando você especifica um faceta na query. Contém os seguintes campos:
Opção | Tipo | necessidade | Propósito |
---|---|---|---|
| documento | Opcional | Mostra estatísticas somente para o coletor |
| documento | Opcional | Mostra estatísticas relacionadas à criação do objeto Lucene interno que contém todos os agrupamentos de faceta . Ele contém |
| documento | Obrigatório | Mapeia o campo que está sendo facetado em suas cardinalidades para os documentos que corresponderam à query e em todo o índice Lucene. Ela fornece as seguintes informações de cardinalidade para cada campo:
|
sort
O sort
é um documento BSON que detalha a estatística de query e execução quando você especifica uma classificação na query. Contém os seguintes campos:
Opção | Tipo | necessidade | Propósito |
---|---|---|---|
| documento | Opcional | Rastreia estatísticas relacionadas à execução de
|
| documento | Obrigatório | Mapeia o campo que está sendo classificado na lista de tipos de dados presentes no índice do campo. |
highlight
O highlight
é um documento BSON que detalha a estatística de query e execução quando você especifica o realce na query. Contém os seguintes campos:
Opção | Tipo | necessidade | Propósito |
---|---|---|---|
| List<String> | Obrigatório | Lista de todos os campos destacados. Se você especificou um caminho curinga na seção |
| QueryExecutionArea | Opcional | Estatísticas de invocação e tempo relacionadas à configuração e execução de destaques. Contém os seguintes campos:
|
indexPartitionExplain
o indexPartitionExplain
contém Explicar Resultados para cada partição de índice. O e o collectors
query
de nível superior estão dentro explain
das informações de cada partição do índice e ausentes no nível superior.
metadata
O metadata
contém metadados úteis, como os seguintes:
Opção | Tipo | necessidade | Propósito |
---|---|---|---|
| String | Opcional | Versão atual do |
| String | Opcional | Etiqueta legível por humanos que identifica o host |
| String | Opcional | Índice do Atlas Search usado na query. |
| Documento | Opcional | Opções de cursor dadas ao mongot. |
| Inteiro | Opcional | Número total de documentos lucene no índice, incluindo documentos excluídos. |
query
A resposta explain
é um documento BSON com chaves e valores que descrevem a estatística de execução da query. O documento explain
no conjunto de resultados contém os seguintes campos:
Opção | Tipo | necessidade | Propósito |
---|---|---|---|
| string | Opcional | Caminho para o operador, somente se não for a raiz. |
| string | Obrigatório | Nome da query Lucene que o operador do Atlas Search criou. Consulte |
| string | Opcional | O analisador do Atlas Search usado com a query. |
| documento | Obrigatório | Informações sobre a query do Lucene. Consulte |
| documento | Opcional |
|
args
A resposta de explicação de um comando de pesquisa contém informações sobre a query executada com esse comando. A resposta no args
campo inclui detalhes estruturados de quais queries do Lucene foram executadas Atlas Search para satisfazer uma $search
query.
Esta seção contém:
Algumas das queries do Lucene que os operadores do Atlas Search criam
Opções de query do Lucene incluídas no resumo estruturado
Exemplo de resumo estruturado da query Lucene para cada tipo de query Lucene
Observação
Sobre os exemplos
Os exemplos desta seção são baseados em queries executadas nos conjuntos de dados de amostra com o queryPlanner
modo de verbosidade. Na resposta de exemplo :
mongotQuery
o campo mostra o operador Atlas Search e a query que foi executada.explain.type
mostra a query Lucene que o operador criou.
Para obter exemplos completos, consulte Exemplos.
BooleanQuery
Para Lucene
BooleanQuery
, o resumo estruturado inclui detalhes sobre as seguintes opções:CampoTiponecessidadeDescriçãomust
Opcional
Cláusulas que devem corresponder.
mustNot
Opcional
Cláusulas que não devem corresponder.
should
Opcional
Cláusulas que deveriam corresponder.
filter
Opcional
Cláusulas que deveriam corresponder.
minimumShouldMatch
Inteiro
Opcional
O número mínimo de
should
cláusulas que devem corresponder.
ConstantScoreQuery
Para consultas de pontuação constantes, o resumo estruturado inclui detalhes sobre as seguintes opções:
CampoTiponecessidadeDescriçãoquery
Obrigatório
Filho de
ConstantScoreQuery
.O exemplo a seguir mostra a resposta
explain
para uma query executada na coleçãosample_airbnb.listingsAndReviews
.1 { 2 "stages" : [ 3 { 4 "$_internalSearchMongotRemote" : { 5 "mongotQuery" : { 6 "equals" : { 7 "path" : "host.host_identity_verified", 8 "value" : true 9 } 10 }, 11 "explain" : { 12 "type" : "ConstantScoreQuery", 13 "args" : { 14 "query" : { 15 "type" : "TermQuery", 16 "args" : { 17 "path" : "host.host_identity_verified", 18 "value" : "T" 19 } 20 } 21 } 22 } 23 } 24 }, 25 { 26 "$_internalSearchIdLookup" : { } 27 } 28 ], 29 ... 30 }
FunctionScoreQuery
Para consultas do Lucene
FunctionScoreQuery
, o resumo estruturado inclui detalhes sobre as seguintes opções:CampoTiponecessidadeDescriçãoscoreFunction
string
Obrigatório
Expressão de pontuação usada na consulta.
query
Obrigatório
A consulta.
O exemplo a seguir mostra a resposta
explain
para uma query executada na coleçãosample_airbnb.listingsAndReviews
.1 { 2 "stages" : [ 3 { 4 "$_internalSearchMongotRemote" : { 5 "mongotQuery" : { 6 "near" : { 7 "path" : "accomodates", 8 "origin" : 8, 9 "pivot" : 2 10 } 11 }, 12 "explain" : { 13 "type" : "BooleanQuery", 14 "args" : { 15 "must" : [ ], 16 "mustNot" : [ ], 17 "should" : [ 18 { 19 "type" : "BooleanQuery", 20 "args" : { 21 "must" : [ ], 22 "mustNot" : [ ], 23 "should" : [ 24 { 25 "type" : "FunctionScoreQuery", 26 "args" : { 27 "scoreFunction" : "expr(pivot / (pivot + abs(origin - value)))", 28 "query" : { 29 "type" : "LongDistanceFeatureQuery", 30 "args" : { }, 31 "stats" : { } 32 } 33 } 34 } 35 ], 36 "filter" : [ 37 { 38 "type" : "PointRangeQuery", 39 "args" : { 40 "path" : "accomodates", 41 "representation" : "double", 42 "gte" : 8.000000000000002, 43 "lte" : NaN 44 } 45 } 46 ], 47 "minimumShouldMatch" : 0 48 } 49 }, 50 { 51 "type" : "LongDistanceFeatureQuery", 52 "args" : { }, 53 "stats" : { } 54 } 55 ], 56 "filter" : [ ], 57 "minimumShouldMatch" : 0 58 } 59 } 60 }, 61 ... 62 }, 63 ... 64 ], 65 ... 66 }
LatLonPointDistanceQuery
Para
LatLonPointDistanceQuery
consultas do Lucene, a resposta contém apenasstats
um.O exemplo a seguir mostra a resposta
explain
para uma query executada na coleçãosample_airbnb.listingsAndReviews
.1 { 2 "stages" : [ 3 { 4 "$_internalSearchMongotRemote" : { 5 "mongotQuery" : { 6 "geoWithin" : { 7 "path" : "address.location", 8 "circle" : { 9 "radius" : 4800, 10 "center" : { 11 "type" : "Point", 12 "coordinates" : [ 13 -122.419472, 14 37.765302 15 ] 16 } 17 } 18 } 19 }, 20 "explain" : { 21 "type" : "LatLonPointDistanceQuery", 22 "args" : { } 23 } 24 } 25 }, 26 ... 27 ], 28 ... 29 }
LatLonShapeQuery
Para
LatLonShapeQuery
consultas do Lucene, a resposta contém apenasstats
um.O exemplo a seguir mostra a resposta
explain
para uma query executada na coleçãosample_airbnb.listingsAndReviews
.1 { 2 "stages" : [ 3 { 4 "$_internalSearchMongotRemote" : { 5 "mongotQuery" : { 6 "geoShape" : { 7 "path" : "address.location", 8 "relation" : "within", 9 "geometry" : { 10 "type" : "Polygon", 11 "coordinates" : [ 12 [ 13 [ -74.3994140625, 40.5305017757 ], 14 [ -74.7290039063, 40.5805846641 ], 15 [ -74.7729492188, 40.9467136651 ], 16 [ -74.0698242188, 41.1290213475 ], 17 [ -73.65234375, 40.9964840144 ], 18 [ -72.6416015625, 40.9467136651 ], 19 [ -72.3559570313, 40.7971774152 ], 20 [ -74.3994140625, 40.5305017757 ] 21 ] 22 ] 23 } 24 } 25 }, 26 "explain" : { 27 "type" : "LatLonShapeQuery", 28 "args" : { } 29 } 30 }, 31 ... 32 }, 33 ... 34 ], 35 ... 36 }
LongDistanceFeatureQuery
Para Lucene,
LongDistanceFeatureQuery
a resposta contém apenas umstats
.O exemplo a seguir mostra a resposta
explain
para uma query executada na coleçãosample_mflix.movies
.1 { 2 "stages" : [ 3 { 4 "$_internalSearchMongotRemote" : { 5 "mongotQuery" : { 6 "near" : { 7 "path" : "released", 8 "origin" : ISODate("1915-09-13T00:00:00Z"), 9 "pivot" : 7776000000 10 } 11 }, 12 "explain" : { 13 "type" : "LongDistanceFeatureQuery", 14 "args" : { } 15 } 16 }, 17 ... 18 }, 19 ... 20 ], 21 ... 22 }
MultiTermQueryConstantScoreWrapper
O exemplo a seguir mostra a resposta
explain
para uma query executada na coleçãosample_airbnb.listingsAndReviews
.1 { 2 "stages" : [ 3 { 4 "$_internalSearchMongotRemote" : { 5 "mongotQuery" : { 6 "regex" : { 7 "path" : "access", 8 "query" : "full(.{0,5})", 9 "allowAnalyzedField" : true 10 } 11 }, 12 "explain" : { 13 "type" : "MultiTermQueryConstantScoreWrapper", 14 "args" : { 15 "queries" : [ 16 { 17 "type" : "DefaultQuery", 18 "args" : { 19 "queryType" : "RegexpQuery" 20 } 21 } 22 ] 23 } 24 } 25 }, 26 ... 27 }, 28 ... 29 ], 30 ... 31 }
PhraseQuery
Para consultas do Lucene
PhraseQuery
, o resumo estruturado inclui detalhes sobre os seguintes argumentos:CampoTiponecessidadeDescriçãopath
String
Obrigatório
Campo indexado para pesquisar.
query
String
Obrigatório
String ou strings para pesquisar.
slop
Número
Obrigatório
Distância permitida entre palavras na frase
query
.O exemplo a seguir mostra a resposta
explain
para uma query executada na coleçãosample_airbnb.listingsAndReviews
.1 { 2 "stages" : [ 3 { 4 "$_internalSearchMongotRemote" : { 5 "mongotQuery" : { 6 "phrase" : { 7 "path" : "description", 8 "query" : "comfortable apartment", 9 "slop" : 2 10 } 11 }, 12 "explain" : { 13 "type" : "PhraseQuery", 14 "args" : { 15 "path" : "description", 16 "query" : "[comfortable, apartment]", 17 "slop" : 2 18 } 19 } 20 }, 21 ... 22 }, 23 ... 24 ], 25 ... 26 }
PointRangeQuery
Para consultas do Lucene
PointRangeQuery
, o resumo estruturado inclui detalhes sobre os seguintes argumentos:CampoTiponecessidadeDescriçãopath
String
Obrigatório
Campo indexado para pesquisar.
representation
String
Opcional
Representação numérica. Queries sobre dados classificados por data não incluem representação.
gte
Número
Opcional
Limite inferior da consulta.
lte
Número
Opcional
Limite superior da consulta.
O exemplo a seguir mostra a resposta
explain
para uma query executada na coleçãosample_airbnb.listingsAndReviews
.1 { 2 "stages" : [ 3 { 4 "$_internalSearchMongotRemote" : { 5 "mongotQuery" : { 6 "range" : { 7 "path" : "number_of_reviews", 8 "gt" : 5 9 } 10 }, 11 "explain" : { 12 "type" : "BooleanQuery", 13 "args" : { 14 "must" : [ ], 15 "mustNot" : [ ], 16 "should" : [ 17 { 18 "type" : "PointRangeQuery", 19 "args" : { 20 "path" : "number_of_reviews", 21 "representation" : "double", 22 "gte" : 5.000000000000001 23 } 24 }, 25 { 26 "type" : "PointRangeQuery", 27 "args" : { 28 "path" : "number_of_reviews", 29 "representation" : "int64", 30 "gte" : NumberLong(6) 31 } 32 } 33 ], 34 "filter" : [ ], 35 "minimumShouldMatch" : 0 36 } 37 } 38 }, 39 ... 40 }, 41 ... 42 ], 43 ... 44 }
TermQuery
Para queries de termo, o resumo estruturado inclui detalhes sobre os seguintes argumentos:
CampoTiponecessidadeDescriçãopath
String
Obrigatório
Campo indexado para pesquisar.
value
String
Obrigatório
String a ser pesquisada.
O exemplo a seguir mostra a resposta
explain
para uma query executada na coleçãosample_airbnb.listingsAndReviews
.1 { 2 "stages" : [ 3 { 4 "$_internalSearchMongotRemote" : { 5 "mongotQuery" : { 6 "queryString" : { 7 "defaultPath" : "summary", 8 "query" : "quiet" 9 } 10 }, 11 "explain" : { 12 "type" : "TermQuery", 13 "args" : { 14 "path" : "summary", 15 "value" : "quiet" 16 } 17 } 18 }, 19 ... 20 }, 21 ... 22 ], 23 ... 24 }
Default
Queries Lucene que não são explicitamente definidas por outra query Lucene são serializadas utilizando a query padrão. O resumo estruturado inclui detalhes sobre a seguinte opção:
CampoTiponecessidadeDescriçãoqueryType
String
Obrigatório.
Tipo de consulta Lucene.
O exemplo a seguir mostra a resposta
explain
para uma query executada na coleçãosample_airbnb.listingsAndReviews
.1 { 2 "stages" : [ 3 { 4 "$_internalSearchMongotRemote" : { 5 "mongotQuery" : { 6 "near" : { 7 "origin" : { 8 "type" : "Point", 9 "coordinates" : [ 10 -8.61308, 11 41.1413 12 ] 13 }, 14 "pivot" : 1000, 15 "path" : "address.location" 16 } 17 }, 18 "explain" : { 19 "type" : "DefaultQuery", 20 "args" : { 21 "queryType" : "LatLonPointDistanceFeatureQuery" 22 } 23 } 24 }, 25 ... 26 }, 27 ... 28 ], 29 ... 30 }
stats
A resposta explain
para os modos de detalhamento executionStats e allPlansExecution inclui um campo stats
que contém informações sobre quanto tempo uma query gasta em vários estágios de sua execução.
Detalhamento do tempo
O detalhamento do tempo descreve as estatísticas de execução pertinentes a uma área de execução da query . Os campos a seguir mostram o detalhamento do tempo:
Campo | Tipo | Descrição |
---|---|---|
| Long | |
| Docuemnt |
Áreas de query
As estatísticas estão disponíveis para as seguintes áreas de query:
Opção | Descrição | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
| Estatísticas relacionadas à execução da query Lucene. Há duas tarefas cujas contagens de invocação são enumeradas nesta área:
O tempo gasto nessa área está relacionado à estrutura da query e não é baseado no número de resultados que são iterados e pontuados. Por exemplo:
| |||||||||||
| Estatísticas relacionadas à iteração e à correspondência de documentos de resultados. Essa estatística mostra o tempo necessário para determinar qual documento é a próxima correspondência. O tempo gasto na correspondência de resultados pode variar significativamente, dependendo da natureza da query. Há duas tarefas cujas contagens de invocação são enumeradas nesta área:
Por exemplo:
| |||||||||||
| Estatísticas relacionadas à pontuação de documentos no conjunto de resultados. Há duas tarefas cujas contagens de invocação são enumeradas nesta área:
Por exemplo:
|
resultMaterialization
O resultMaterialization
monitora a quantidade de tempo que o mongot
leva para realizar o seguinte:
Recupere dados de resultados armazenados no Lucene na forma de
_id
oustoredSource
.Serialize os dados no formato BSON antes de enviá-los
mongod
para.
resourceUsage
O resourceUsage
rastreia o recurso usado para executar a query. Contém os seguintes campos:
Opção | Tipo | necessidade | Propósito |
---|---|---|---|
| Long | Obrigatório | Número de falhas de páginas principais, que ocorrem quando o sistema não consegue encontrar os dados necessários na memória, resultando na leitura do armazenamento de backup, como disco, durante a execução da query. |
| Long | Obrigatório | Número de falhas de página menores, que ocorrem quando os dados estão no cache da página, mas ainda não foram mapeados para a tabela de páginas do processo. |
| Long | Obrigatório | Quantidade de tempo de CPU, em milissegundos, gasto no espaço do usuário. |
| Long | Obrigatório | Quantidade de tempo da CPU, em milissegundos, gasto no espaço do sistema. |
| Inteiro | Obrigatório | Número máximo de threads que |
| Inteiro | Obrigatório | Número total de lotes que |
Exemplos
Os exemplos seguintes utilizam a collection movies
no banco de dados sample_mflix
.
Dica
Se você já carregou o conjunto de dados de amostra, siga o tutorial Iniciar com Atlas Search para criar uma definição de índice e executar queries de Atlas Search.
allPlansExecution
O exemplo a seguir usa operadores diferentes para consultar o title
campo com o allPlansExecution
modo de detalhamento.
db.movies.explain("allPlansExecution").aggregate([ { $search: { "text": { "path": "title", "query": "yark", "fuzzy": { "maxEdits": 1, "maxExpansions": 100, } } } } ])
1 { 2 explainVersion: '1', 3 stages: [ 4 { 5 '$_internalSearchMongotRemote': { 6 mongotQuery: { 7 text: { 8 path: 'title', 9 query: 'yark', 10 fuzzy: { maxEdits: 1, maxExpansions: 100 } 11 } 12 }, 13 explain: { 14 query: { 15 type: 'BooleanQuery', 16 args: { 17 must: [], 18 mustNot: [], 19 should: [ 20 { 21 type: 'BoostQuery', 22 args: { 23 query: { 24 type: 'TermQuery', 25 args: { path: 'title', value: 'dark' }, 26 stats: { 27 context: { millisElapsed: 0 }, 28 match: { millisElapsed: 0 }, 29 score: { millisElapsed: 0 } 30 } 31 }, 32 boost: 0.75 33 }, 34 stats: { 35 context: { 36 millisElapsed: 0.403983, 37 invocationCounts: { 38 createWeight: Long('1'), 39 createScorer: Long('18') 40 } 41 }, 42 match: { 43 millisElapsed: 0.094254, 44 invocationCounts: { nextDoc: Long('89') } 45 }, 46 score: { 47 millisElapsed: 0.077043, 48 invocationCounts: { score: Long('83') } 49 } 50 } 51 }, 52 { 53 type: 'BoostQuery', 54 args: { 55 query: { 56 type: 'TermQuery', 57 args: { path: 'title', value: 'ark' }, 58 stats: { 59 context: { millisElapsed: 0 }, 60 match: { millisElapsed: 0 }, 61 score: { millisElapsed: 0 } 62 } 63 }, 64 boost: 0.6666666269302368 65 }, 66 stats: { 67 context: { 68 millisElapsed: 0.248528, 69 invocationCounts: { 70 createWeight: Long('1'), 71 createScorer: Long('8') 72 } 73 }, 74 match: { 75 millisElapsed: 0.067561, 76 invocationCounts: { nextDoc: Long('3') } 77 }, 78 score: { 79 millisElapsed: 0.001649, 80 invocationCounts: { score: Long('2') } 81 } 82 } 83 }, 84 { 85 type: 'BoostQuery', 86 args: { 87 query: { 88 type: 'TermQuery', 89 args: { path: 'title', value: 'mark' }, 90 stats: { 91 context: { millisElapsed: 0 }, 92 match: { millisElapsed: 0 }, 93 score: { millisElapsed: 0 } 94 } 95 }, 96 boost: 0.75 97 }, 98 stats: { 99 context: { 100 millisElapsed: 0.337083, 101 invocationCounts: { 102 createWeight: Long('1'), 103 createScorer: Long('12') 104 } 105 }, 106 match: { 107 millisElapsed: 0.006489, 108 invocationCounts: { nextDoc: Long('11') } 109 }, 110 score: { 111 millisElapsed: 0.013741, 112 invocationCounts: { score: Long('8') } 113 } 114 } 115 }, 116 { 117 type: 'BoostQuery', 118 args: { 119 query: { 120 type: 'TermQuery', 121 args: { path: 'title', value: 'park' }, 122 stats: { 123 context: { millisElapsed: 0 }, 124 match: { millisElapsed: 0 }, 125 score: { millisElapsed: 0 } 126 } 127 }, 128 boost: 0.75 129 }, 130 stats: { 131 context: { 132 millisElapsed: 0.395528, 133 invocationCounts: { 134 createWeight: Long('1'), 135 createScorer: Long('16') 136 } 137 }, 138 match: { 139 millisElapsed: 0.091681, 140 invocationCounts: { nextDoc: Long('32') } 141 }, 142 score: { 143 millisElapsed: 0.137827, 144 invocationCounts: { score: Long('27') } 145 } 146 } 147 }, 148 { 149 type: 'BoostQuery', 150 args: { 151 query: { 152 type: 'TermQuery', 153 args: { path: 'title', value: 'york' }, 154 stats: { 155 context: { millisElapsed: 0 }, 156 match: { millisElapsed: 0 }, 157 score: { millisElapsed: 0 } 158 } 159 }, 160 boost: 0.75 161 }, 162 stats: { 163 context: { 164 millisElapsed: 0.150681, 165 invocationCounts: { 166 createWeight: Long('1'), 167 createScorer: Long('16') 168 } 169 }, 170 match: { 171 millisElapsed: 0.067298, 172 invocationCounts: { nextDoc: Long('33') } 173 }, 174 score: { 175 millisElapsed: 0.038636, 176 invocationCounts: { score: Long('28') } 177 } 178 } 179 }, 180 { 181 type: 'BoostQuery', 182 args: { 183 query: { 184 type: 'TermQuery', 185 args: { path: 'title', value: 'yard' }, 186 stats: { 187 context: { millisElapsed: 0 }, 188 match: { millisElapsed: 0 }, 189 score: { millisElapsed: 0 } 190 } 191 }, 192 boost: 0.75 193 }, 194 stats: { 195 context: { 196 millisElapsed: 0.104308, 197 invocationCounts: { 198 createWeight: Long('1'), 199 createScorer: Long('8') 200 } 201 }, 202 match: { 203 millisElapsed: 0.002445, 204 invocationCounts: { nextDoc: Long('4') } 205 }, 206 score: { 207 millisElapsed: 0.00233, 208 invocationCounts: { score: Long('3') } 209 } 210 } 211 } 212 ], 213 filter: [], 214 minimumShouldMatch: 0 215 }, 216 stats: { 217 context: { 218 millisElapsed: 12.8127, 219 invocationCounts: { createWeight: Long('1'), createScorer: Long('12') } 220 }, 221 match: { 222 millisElapsed: 0.761076, 223 invocationCounts: { nextDoc: Long('157') } 224 }, 225 score: { 226 millisElapsed: 0.857125, 227 invocationCounts: { score: Long('151') } 228 } 229 } 230 }, 231 collectors: { 232 allCollectorStats: { 233 millisElapsed: 2.061296, 234 invocationCounts: { 235 collect: Long('151'), 236 competitiveIterator: Long('6'), 237 setScorer: Long('6') 238 } 239 }, 240 facet: { collectorStats: { millisElapsed: 0 } } 241 }, 242 resultMaterialization: { 243 stats: { 244 millisElapsed: 17.759502, 245 invocationCounts: { retrieveAndSerialize: Long('1') } 246 } 247 }, 248 metadata: { 249 mongotVersion: '1.43.1', 250 mongotHostName: 'atlas-11decp-shard-00-02.2rnul.mongodb-dev.net', 251 indexName: 'default', 252 totalLuceneDocs: 21349 253 }, 254 resourceUsage: { 255 majorFaults: Long('0'), 256 minorFaults: Long('98'), 257 userTimeMs: Long('30'), 258 systemTimeMs: Long('0'), 259 maxReportingThreads: 1, 260 numBatches: 1 261 } 262 }, 263 requiresSearchMetaCursor: true 264 }, 265 nReturned: Long('0'), 266 executionTimeMillisEstimate: Long('108') 267 }, 268 { 269 '$_internalSearchIdLookup': {}, 270 nReturned: Long('0'), 271 executionTimeMillisEstimate: Long('108') 272 } 273 ], 274 queryShapeHash: '6FD3791F785FA329D4ECD1171E0E5AF6772C18F5F0A7A50FC416D080A93C8CB7', 275 serverInfo: { 276 host: 'atlas-11decp-shard-00-02.2rnul.mongodb-dev.net', 277 port: 27017, 278 version: '8.0.4', 279 gitVersion: 'bc35ab4305d9920d9d0491c1c9ef9b72383d31f9' 280 }, 281 serverParameters: { 282 ... 283 }, 284 command: { 285 aggregate: 'movies', 286 pipeline: [ 287 { 288 '$search': { 289 text: { 290 path: 'title', 291 query: 'yark', 292 fuzzy: { maxEdits: 1, maxExpansions: 100 } 293 } 294 } 295 } 296 ], 297 cursor: {}, 298 '$db': 'sample_mflix' 299 }, 300 ok: 1, 301 '$clusterTime': { 302 clusterTime: Timestamp({ t: 1738081279, i: 12 }), 303 signature: { 304 hash: Binary.createFromBase64('DM3imkEw1qT23M2n/b/JibqB1Fg=', 0), 305 keyId: Long('7462787091647168517') 306 } 307 }, 308 operationTime: Timestamp({ t: 1738081279, i: 12 }) 309 }
db.movies.explain("allPlansExecution").aggregate([ { $search: { "text": { "path": "title", "query": "prince" }, "highlight": { "path": "title", "maxNumPassages": 1, "maxCharsToExamine": 40 } } }, { $project: { "description": 1, "_id": 0, "highlights": { "$meta": "searchHighlights" } } } ])
1 { 2 explainVersion: '1', 3 stages: [ 4 { 5 '$_internalSearchMongotRemote': { 6 mongotQuery: { 7 text: { path: 'title', query: 'prince' }, 8 highlight: { path: 'title', maxNumPassages: 1, maxCharsToExamine: 40 } 9 }, 10 explain: { 11 query: { 12 type: 'TermQuery', 13 args: { path: 'title', value: 'prince' }, 14 stats: { 15 context: { 16 millisElapsed: 1.034149, 17 invocationCounts: { createWeight: Long('1'), createScorer: Long('10') } 18 }, 19 match: { 20 millisElapsed: 0.050591, 21 invocationCounts: { nextDoc: Long('29') } 22 }, 23 score: { 24 millisElapsed: 0.027259, 25 invocationCounts: { score: Long('25') } 26 } 27 } 28 }, 29 collectors: { 30 allCollectorStats: { 31 millisElapsed: 0.112751, 32 invocationCounts: { 33 collect: Long('25'), 34 competitiveIterator: Long('4'), 35 setScorer: Long('4') 36 } 37 }, 38 facet: { collectorStats: { millisElapsed: 0 } } 39 }, 40 highlight: { 41 resolvedHighlightPaths: [ '$type:string/title' ], 42 stats: { 43 millisElapsed: 10.665238, 44 invocationCounts: { 45 executeHighlight: Long('1'), 46 setupHighlight: Long('1') 47 } 48 } 49 }, 50 resultMaterialization: { 51 stats: { 52 millisElapsed: 3.548075, 53 invocationCounts: { retrieveAndSerialize: Long('1') } 54 } 55 }, 56 metadata: { 57 mongotVersion: '1.43.1', 58 mongotHostName: 'atlas-11decp-shard-00-02.2rnul.mongodb-dev.net', 59 indexName: 'default', 60 totalLuceneDocs: 21349 61 }, 62 resourceUsage: { 63 majorFaults: Long('0'), 64 minorFaults: Long('0'), 65 userTimeMs: Long('10'), 66 systemTimeMs: Long('0'), 67 maxReportingThreads: 1, 68 numBatches: 1 69 } 70 }, 71 requiresSearchMetaCursor: true 72 }, 73 nReturned: Long('0'), 74 executionTimeMillisEstimate: Long('31') 75 }, 76 { 77 '$_internalSearchIdLookup': {}, 78 nReturned: Long('0'), 79 executionTimeMillisEstimate: Long('31') 80 }, 81 { 82 '$project': { 83 description: true, 84 highlights: { '$meta': 'searchHighlights' }, 85 _id: false 86 }, 87 nReturned: Long('0'), 88 executionTimeMillisEstimate: Long('31') 89 } 90 ], 91 queryShapeHash: 'D08444272924C1E04A6E99D0CD4BF82FD929893862B3356F79EC18BBD1F0EF0C', 92 serverInfo: { 93 host: 'atlas-11decp-shard-00-02.2rnul.mongodb-dev.net', 94 port: 27017, 95 version: '8.0.4', 96 gitVersion: 'bc35ab4305d9920d9d0491c1c9ef9b72383d31f9' 97 }, 98 serverParameters: { 99 internalQueryFacetBufferSizeBytes: 104857600, 100 internalQueryFacetMaxOutputDocSizeBytes: 104857600, 101 internalLookupStageIntermediateDocumentMaxSizeBytes: 104857600, 102 internalDocumentSourceGroupMaxMemoryBytes: 104857600, 103 internalQueryMaxBlockingSortMemoryUsageBytes: 104857600, 104 internalQueryProhibitBlockingMergeOnMongoS: 0, 105 internalQueryMaxAddToSetBytes: 104857600, 106 internalDocumentSourceSetWindowFieldsMaxMemoryBytes: 104857600, 107 internalQueryFrameworkControl: 'trySbeRestricted', 108 internalQueryPlannerIgnoreIndexWithCollationForRegex: 1 109 }, 110 command: { 111 aggregate: 'movies', 112 pipeline: [ 113 { 114 '$search': { 115 text: { path: 'title', query: 'prince' }, 116 highlight: { path: 'title', maxNumPassages: 1, maxCharsToExamine: 40 } 117 } 118 }, 119 { 120 '$project': { 121 description: 1, 122 _id: 0, 123 highlights: { '$meta': 'searchHighlights' } 124 } 125 } 126 ], 127 cursor: {}, 128 '$db': 'sample_mflix' 129 }, 130 ok: 1, 131 '$clusterTime': { 132 clusterTime: Timestamp({ t: 1738081637, i: 1 }), 133 signature: { 134 hash: Binary.createFromBase64('TnFwebZsmrjLunk7/TN+9rfJ/8Y=', 0), 135 keyId: Long('7462787091647168517') 136 } 137 }, 138 operationTime: Timestamp({ t: 1738081637, i: 1 }) 139 }
db.movies.explain("allPlansExecution").aggregate([ { "$searchMeta": { "facet": { "operator": { "near": { "path": "released", "origin": ISODate("1921-11-01T00:00:00.000+00:00"), "pivot": 7776000000 } }, "facets": { "genresFacet": { "type": "string", "path": "genres" }, "yearFacet" : { "type" : "number", "path" : "year", "boundaries" : [1910,1920,1930,1940] } } } } } ])
1 { 2 explainVersion: '1', 3 stages: [ 4 { 5 '$searchMeta': { 6 mongotQuery: { 7 facet: { 8 operator: { 9 near: { 10 path: 'released', 11 origin: ISODate('1921-11-01T00:00:00.000Z'), 12 pivot: 7776000000 13 } 14 }, 15 facets: { 16 genresFacet: { type: 'string', path: 'genres' }, 17 yearFacet: { 18 type: 'number', 19 path: 'year', 20 boundaries: [ 1910, 1920, 1930, 1940 ] 21 } 22 } 23 } 24 }, 25 explain: { 26 query: { 27 type: 'LongDistanceFeatureQuery', 28 args: {}, 29 stats: { 30 context: { 31 millisElapsed: 0.684076, 32 invocationCounts: { createWeight: Long('1'), createScorer: Long('12') } 33 }, 34 match: { 35 millisElapsed: 1.285512, 36 invocationCounts: { nextDoc: Long('20884') } 37 }, 38 score: { 39 millisElapsed: 1.321738, 40 invocationCounts: { score: Long('20878') } 41 } 42 } 43 }, 44 collectors: { 45 allCollectorStats: { 46 millisElapsed: 10.536043, 47 invocationCounts: { 48 collect: Long('20878'), 49 competitiveIterator: Long('6'), 50 setScorer: Long('6') 51 } 52 }, 53 facet: { 54 collectorStats: { 55 millisElapsed: 3.730834, 56 invocationCounts: { collect: Long('20878'), setScorer: Long('6') } 57 }, 58 createCountsStats: { 59 millisElapsed: 10.350302, 60 invocationCounts: { generateFacetCounts: Long('2') } 61 }, 62 stringFacetCardinalities: { genresFacet: { queried: 10, total: 25 } } 63 } 64 }, 65 resultMaterialization: { 66 stats: { 67 millisElapsed: 10.645713, 68 invocationCounts: { retrieveAndSerialize: Long('1') } 69 } 70 }, 71 metadata: { 72 mongotVersion: '1.43.1', 73 mongotHostName: 'atlas-11decp-shard-00-02.2rnul.mongodb-dev.net', 74 indexName: 'default', 75 totalLuceneDocs: 21349 76 }, 77 resourceUsage: { 78 majorFaults: Long('0'), 79 minorFaults: Long('0'), 80 userTimeMs: Long('10'), 81 systemTimeMs: Long('0'), 82 maxReportingThreads: 1, 83 numBatches: 1 84 } 85 }, 86 requiresSearchMetaCursor: true 87 }, 88 nReturned: Long('0'), 89 executionTimeMillisEstimate: Long('57') 90 } 91 ], 92 queryShapeHash: '582DB864C9BCFB96896CF1A3079CF70FAC10A9A1E19E8D66DF20A2BB40424FB5', 93 serverInfo: { 94 host: 'atlas-11decp-shard-00-02.2rnul.mongodb-dev.net', 95 port: 27017, 96 version: '8.0.4', 97 gitVersion: 'bc35ab4305d9920d9d0491c1c9ef9b72383d31f9' 98 }, 99 serverParameters: { 100 internalQueryFacetBufferSizeBytes: 104857600, 101 internalQueryFacetMaxOutputDocSizeBytes: 104857600, 102 internalLookupStageIntermediateDocumentMaxSizeBytes: 104857600, 103 internalDocumentSourceGroupMaxMemoryBytes: 104857600, 104 internalQueryMaxBlockingSortMemoryUsageBytes: 104857600, 105 internalQueryProhibitBlockingMergeOnMongoS: 0, 106 internalQueryMaxAddToSetBytes: 104857600, 107 internalDocumentSourceSetWindowFieldsMaxMemoryBytes: 104857600, 108 internalQueryFrameworkControl: 'trySbeRestricted', 109 internalQueryPlannerIgnoreIndexWithCollationForRegex: 1 110 }, 111 command: { 112 aggregate: 'movies', 113 pipeline: [ 114 { 115 '$searchMeta': { 116 facet: { 117 operator: { 118 near: { 119 path: 'released', 120 origin: ISODate('1921-11-01T00:00:00.000Z'), 121 pivot: 7776000000 122 } 123 }, 124 facets: { 125 genresFacet: { type: 'string', path: 'genres' }, 126 yearFacet: { 127 type: 'number', 128 path: 'year', 129 boundaries: [ 1910, 1920, 1930, 1940 ] 130 } 131 } 132 } 133 } 134 } 135 ], 136 cursor: {}, 137 '$db': 'sample_mflix' 138 }, 139 ok: 1, 140 '$clusterTime': { 141 clusterTime: Timestamp({ t: 1738081767, i: 1 }), 142 signature: { 143 hash: Binary.createFromBase64('ieRjqe84DdOnmlCcP3XBelo8vyM=', 0), 144 keyId: Long('7462787091647168517') 145 } 146 }, 147 operationTime: Timestamp({ t: 1738081767, i: 1 }) 148 }
queryPlanner
O exemplo a seguir usa operadores diferentes para consultar o title
campo com o queryPlanner
modo de detalhamento.
db.movies.explain("queryPlanner").aggregate([ { $search: { "text": { "path": "title", "query": "yark", "fuzzy": { "maxEdits": 1, "maxExpansions": 100, } } } } ])
1 { 2 "stages" : [ 3 { 4 "$_internalSearchMongotRemote" : { 5 "mongotQuery" : { 6 "text" : { 7 "path" : "title", 8 "query" : "yark", 9 "fuzzy" : { 10 "maxEdits" : 1, 11 "maxExpansions" : 100 12 } 13 } 14 }, 15 "explain" : { 16 "type" : "BooleanQuery", 17 "args" : { 18 "must" : [ ], 19 "mustNot" : [ ], 20 "should" : [ 21 { 22 "type" : "BoostQuery", 23 "args" : { 24 "query" : { 25 "type" : "TermQuery", 26 "args" : { 27 "path" : "title", 28 "value" : "ark" 29 } 30 }, 31 "boost" : 0.6666666269302368 32 } 33 }, 34 { 35 "type" : "BoostQuery", 36 "args" : { 37 "query" : { 38 "type" : "TermQuery", 39 "args" : { 40 "path" : "title", 41 "value" : "yard" 42 } 43 }, 44 "boost" : 0.75 45 } 46 }, 47 { 48 "type" : "BoostQuery", 49 "args" : { 50 "query" : { 51 "type" : "TermQuery", 52 "args" : { 53 "path" : "title", 54 "value" : "mark" 55 } 56 }, 57 "boost" : 0.75 58 } 59 }, 60 { 61 "type" : "BoostQuery", 62 "args" : { 63 "query" : { 64 "type" : "TermQuery", 65 "args" : { 66 "path" : "title", 67 "value" : "park" 68 } 69 }, 70 "boost" : 0.75 71 } 72 }, 73 { 74 "type" : "BoostQuery", 75 "args" : { 76 "query" : { 77 "type" : "TermQuery", 78 "args" : { 79 "path" : "title", 80 "value" : "dark" 81 } 82 }, 83 "boost" : 0.75 84 } 85 }, 86 { 87 "type" : "BoostQuery", 88 "args" : { 89 "query" : { 90 "type" : "TermQuery", 91 "args" : { 92 "path" : "title", 93 "value" : "york" 94 } 95 }, 96 "boost" : 0.75 97 } 98 } 99 ], 100 "filter" : [ ], 101 "minimumShouldMatch" : 0 102 } 103 } 104 } 105 }, 106 { 107 "$_internalSearchIdLookup" : { } 108 } 109 ], 110 "serverInfo" : { 111 "host" : "atlas-example-shard-00-01.mongodb.net", 112 "port" : 27017, 113 "version" : "4.4.3", 114 "gitVersion" : "913d6b62acfbb344dde1b116f4161360acd8fd13" 115 }, 116 "ok" : 1, 117 "$clusterTime" : { 118 "clusterTime" : Timestamp(1612457287, 1), 119 "signature" : { 120 "hash" : BinData(0,"kzn7hY7NOduVIqcfx+40ENKbMKQ="), 121 "keyId" : NumberLong("1234567890123456789") 122 } 123 }, 124 "operationTime" : Timestamp(1612457287, 1) 125 }
db.movies.explain("queryPlanner").aggregate([ { $search: { "text": { "path": "title", "query": "prince" }, "highlight": { "path": "title", "maxNumPassages": 1, "maxCharsToExamine": 40 } } }, { $project: { "description": 1, "_id": 0, "highlights": { "$meta": "searchHighlights" } } } ])
1 { 2 explainVersion: '1', 3 stages: [ 4 { 5 '$_internalSearchMongotRemote': { 6 mongotQuery: { 7 text: { path: 'title', query: 'prince' }, 8 highlight: { path: 'title', maxNumPassages: 1, maxCharsToExamine: 40 } 9 }, 10 explain: { 11 query: { 12 type: 'TermQuery', 13 args: { path: 'title', value: 'prince' } 14 }, 15 highlight: { resolvedHighlightPaths: [ '$type:string/title' ] }, 16 metadata: { 17 mongotVersion: '1.43.1', 18 mongotHostName: 'atlas-11decp-shard-00-02.2rnul.mongodb-dev.net', 19 indexName: 'default', 20 totalLuceneDocs: 21349 21 } 22 }, 23 requiresSearchMetaCursor: true 24 } 25 }, 26 { '$_internalSearchIdLookup': {} }, 27 { 28 '$project': { 29 description: true, 30 highlights: { '$meta': 'searchHighlights' }, 31 _id: false 32 } 33 } 34 ], 35 queryShapeHash: 'D08444272924C1E04A6E99D0CD4BF82FD929893862B3356F79EC18BBD1F0EF0C', 36 serverInfo: { 37 host: 'atlas-11decp-shard-00-02.2rnul.mongodb-dev.net', 38 port: 27017, 39 version: '8.0.4', 40 gitVersion: 'bc35ab4305d9920d9d0491c1c9ef9b72383d31f9' 41 }, 42 serverParameters: { 43 internalQueryFacetBufferSizeBytes: 104857600, 44 internalQueryFacetMaxOutputDocSizeBytes: 104857600, 45 internalLookupStageIntermediateDocumentMaxSizeBytes: 104857600, 46 internalDocumentSourceGroupMaxMemoryBytes: 104857600, 47 internalQueryMaxBlockingSortMemoryUsageBytes: 104857600, 48 internalQueryProhibitBlockingMergeOnMongoS: 0, 49 internalQueryMaxAddToSetBytes: 104857600, 50 internalDocumentSourceSetWindowFieldsMaxMemoryBytes: 104857600, 51 internalQueryFrameworkControl: 'trySbeRestricted', 52 internalQueryPlannerIgnoreIndexWithCollationForRegex: 1 53 }, 54 command: { 55 aggregate: 'movies', 56 pipeline: [ 57 { 58 '$search': { 59 text: { path: 'title', query: 'prince' }, 60 highlight: { path: 'title', maxNumPassages: 1, maxCharsToExamine: 40 } 61 } 62 }, 63 { 64 '$project': { 65 description: 1, 66 _id: 0, 67 highlights: { '$meta': 'searchHighlights' } 68 } 69 } 70 ], 71 cursor: {}, 72 '$db': 'sample_mflix' 73 }, 74 ok: 1, 75 '$clusterTime': { 76 clusterTime: Timestamp({ t: 1738080637, i: 1 }), 77 signature: { 78 hash: Binary.createFromBase64('fIedxkRaoE5IWmIaN7/BsRC0AJc=', 0), 79 keyId: Long('7462787091647168517') 80 } 81 }, 82 operationTime: Timestamp({ t: 1738080637, i: 1 }) 83 }
db.movies.explain("queryPlanner").aggregate([ { "$searchMeta": { "facet": { "operator": { "near": { "path": "released", "origin": ISODate("1921-11-01T00:00:00.000+00:00"), "pivot": 7776000000 } }, "facets": { "genresFacet": { "type": "string", "path": "genres" }, "yearFacet" : { "type" : "number", "path" : "year", "boundaries" : [1910,1920,1930,1940] } } } } } ])
1 { 2 explainVersion: '1', 3 stages: [ 4 { 5 '$searchMeta': { 6 mongotQuery: { 7 facet: { 8 operator: { 9 near: { 10 path: 'released', 11 origin: ISODate('1921-11-01T00:00:00.000Z'), 12 pivot: 7776000000 13 } 14 }, 15 facets: { 16 genresFacet: { type: 'string', path: 'genres' }, 17 yearFacet: { 18 type: 'number', 19 path: 'year', 20 boundaries: [ 1910, 1920, 1930, 1940 ] 21 } 22 } 23 } 24 }, 25 explain: { 26 query: { type: 'LongDistanceFeatureQuery', args: {} }, 27 collectors: { 28 facet: { 29 stringFacetCardinalities: { genresFacet: { queried: 10, total: 25 } } 30 } 31 }, 32 metadata: { 33 mongotVersion: '1.43.1', 34 mongotHostName: 'atlas-11decp-shard-00-02.2rnul.mongodb-dev.net', 35 indexName: 'default', 36 totalLuceneDocs: 21349 37 } 38 }, 39 requiresSearchMetaCursor: true 40 } 41 } 42 ], 43 queryShapeHash: '582DB864C9BCFB96896CF1A3079CF70FAC10A9A1E19E8D66DF20A2BB40424FB5', 44 serverInfo: { 45 host: 'atlas-11decp-shard-00-02.2rnul.mongodb-dev.net', 46 port: 27017, 47 version: '8.0.4', 48 gitVersion: 'bc35ab4305d9920d9d0491c1c9ef9b72383d31f9' 49 }, 50 serverParameters: { 51 internalQueryFacetBufferSizeBytes: 104857600, 52 internalQueryFacetMaxOutputDocSizeBytes: 104857600, 53 internalLookupStageIntermediateDocumentMaxSizeBytes: 104857600, 54 internalDocumentSourceGroupMaxMemoryBytes: 104857600, 55 internalQueryMaxBlockingSortMemoryUsageBytes: 104857600, 56 internalQueryProhibitBlockingMergeOnMongoS: 0, 57 internalQueryMaxAddToSetBytes: 104857600, 58 internalDocumentSourceSetWindowFieldsMaxMemoryBytes: 104857600, 59 internalQueryFrameworkControl: 'trySbeRestricted', 60 internalQueryPlannerIgnoreIndexWithCollationForRegex: 1 61 }, 62 command: { 63 aggregate: 'movies', 64 pipeline: [ 65 { 66 '$searchMeta': { 67 facet: { 68 operator: { 69 near: { 70 path: 'released', 71 origin: ISODate('1921-11-01T00:00:00.000Z'), 72 pivot: 7776000000 73 } 74 }, 75 facets: { 76 genresFacet: { type: 'string', path: 'genres' }, 77 yearFacet: { 78 type: 'number', 79 path: 'year', 80 boundaries: [ 1910, 1920, 1930, 1940 ] 81 } 82 } 83 } 84 } 85 } 86 ], 87 cursor: {}, 88 '$db': 'sample_mflix' 89 }, 90 ok: 1, 91 '$clusterTime': { 92 clusterTime: Timestamp({ t: 1738080797, i: 1 }), 93 signature: { 94 hash: Binary.createFromBase64('2E8qAEihttRWdJRyCTXRfA1es7I=', 0), 95 keyId: Long('7462787091647168517') 96 } 97 }, 98 operationTime: Timestamp({ t: 1738080797, i: 1 }) 99 }
Para queries que especificam um estágio $limit
no pipeline, os resultados do explain
incluem a métrica mongotDocsRequested
que mostra o número de documentos que o mongod
solicitou do mongot
.
Exemplo
{ "mongotQuery": {}, "explain": {}, "limit": <int>, "sortSpec": {}, "mongotDocsRequested": <int>, }
executionStats
O exemplo a seguir usa o operador autocomplete para fazer uma query do campo title
com o modo de detalhamento executionStats
.
1 db.movies.explain("executionStats").aggregate([ 2 { 3 "$search": { 4 "autocomplete": { 5 "path": "title", 6 "query": "pre", 7 "fuzzy": { 8 "maxEdits": 1, 9 "prefixLength": 1, 10 "maxExpansions": 256 11 } 12 } 13 } 14 } 15 ])
1 { 2 explainVersion: '1', 3 stages: [ 4 { 5 '$_internalSearchMongotRemote': { 6 mongotQuery: { 7 autocomplete: { 8 path: 'title', 9 query: 'pre', 10 fuzzy: { maxEdits: 1, prefixLength: 1, maxExpansions: 256 } 11 } 12 }, 13 explain: { 14 query: { 15 type: 'BooleanQuery', 16 args: { 17 must: [ 18 { 19 type: 'MultiTermQueryConstantScoreBlendedWrapper', 20 args: { 21 queries: [ 22 { 23 type: 'DefaultQuery', 24 args: { queryType: 'AutomatonQuery' }, 25 stats: { 26 context: { millisElapsed: 0 }, 27 match: { millisElapsed: 0 }, 28 score: { millisElapsed: 0 } 29 } 30 } 31 ] 32 }, 33 stats: { 34 context: { 35 millisElapsed: 34.187255, 36 invocationCounts: { 37 createWeight: Long('1'), 38 createScorer: Long('15') 39 } 40 }, 41 match: { 42 millisElapsed: 1.077211, 43 invocationCounts: { nextDoc: Long('812') } 44 }, 45 score: { 46 millisElapsed: 0.274761, 47 invocationCounts: { score: Long('807') } 48 } 49 } 50 } 51 ], 52 mustNot: [], 53 should: [ 54 { 55 type: 'TermQuery', 56 args: { path: 'title', value: 'pre' }, 57 stats: { 58 context: { 59 millisElapsed: 2.495506, 60 invocationCounts: { 61 createWeight: Long('1'), 62 createScorer: Long('5') 63 } 64 }, 65 match: { millisElapsed: 0 }, 66 score: { millisElapsed: 0 } 67 } 68 } 69 ], 70 filter: [], 71 minimumShouldMatch: 0 72 }, 73 stats: { 74 context: { 75 millisElapsed: 43.795864, 76 invocationCounts: { createWeight: Long('1'), createScorer: Long('10') } 77 }, 78 match: { 79 millisElapsed: 1.911068, 80 invocationCounts: { nextDoc: Long('812') } 81 }, 82 score: { 83 millisElapsed: 0.982801, 84 invocationCounts: { score: Long('807') } 85 } 86 } 87 }, 88 collectors: { 89 allCollectorStats: { 90 millisElapsed: 2.51114, 91 invocationCounts: { 92 collect: Long('807'), 93 competitiveIterator: Long('5'), 94 setScorer: Long('5') 95 } 96 }, 97 facet: { collectorStats: { millisElapsed: 0 } } 98 }, 99 resultMaterialization: { 100 stats: { 101 millisElapsed: 10.23124, 102 invocationCounts: { retrieveAndSerialize: Long('1') } 103 } 104 }, 105 metadata: { 106 mongotVersion: '1.43.0', 107 mongotHostName: 'atlas-11decp-shard-00-01.2rnul.mongodb-dev.net', 108 indexName: 'default', 109 totalLuceneDocs: 21349 110 }, 111 resourceUsage: { 112 majorFaults: Long('0'), 113 minorFaults: Long('145'), 114 userTimeMs: Long('30'), 115 systemTimeMs: Long('10'), 116 maxReportingThreads: 1, 117 numBatches: 1 118 } 119 }, 120 requiresSearchMetaCursor: true 121 }, 122 nReturned: Long('0'), 123 executionTimeMillisEstimate: Long('311') 124 }, 125 { 126 '$_internalSearchIdLookup': {}, 127 nReturned: Long('0'), 128 executionTimeMillisEstimate: Long('311') 129 } 130 ], 131 queryShapeHash: '6FD3791F785FA329D4ECD1171E0E5AF6772C18F5F0A7A50FC416D080A93C8CB7', 132 serverInfo: { 133 host: 'atlas-11decp-shard-00-01.2rnul.mongodb-dev.net', 134 port: 27017, 135 version: '8.0.4', 136 gitVersion: 'bc35ab4305d9920d9d0491c1c9ef9b72383d31f9' 137 }, 138 serverParameters: { 139 internalQueryFacetBufferSizeBytes: 104857600, 140 internalQueryFacetMaxOutputDocSizeBytes: 104857600, 141 internalLookupStageIntermediateDocumentMaxSizeBytes: 104857600, 142 internalDocumentSourceGroupMaxMemoryBytes: 104857600, 143 internalQueryMaxBlockingSortMemoryUsageBytes: 104857600, 144 internalQueryProhibitBlockingMergeOnMongoS: 0, 145 internalQueryMaxAddToSetBytes: 104857600, 146 internalDocumentSourceSetWindowFieldsMaxMemoryBytes: 104857600, 147 internalQueryFrameworkControl: 'trySbeRestricted', 148 internalQueryPlannerIgnoreIndexWithCollationForRegex: 1 149 }, 150 command: { 151 aggregate: 'movies', 152 pipeline: [ 153 { 154 '$search': { 155 autocomplete: { 156 path: 'title', 157 query: 'pre', 158 fuzzy: { maxEdits: 1, prefixLength: 1, maxExpansions: 256 } 159 } 160 } 161 } 162 ], 163 cursor: {}, 164 '$db': 'sample_mflix' 165 }, 166 ok: 1, 167 '$clusterTime': { 168 clusterTime: Timestamp({ t: 1737671412, i: 10 }), 169 signature: { 170 hash: Binary.createFromBase64('a3CSqvS0rziAYQCk33WzTo/0Sow=', 0), 171 keyId: Long('7462787091647168517') 172 } 173 }, 174 operationTime: Timestamp({ t: 1737671412, i: 10 }) 175 }
Para saber mais sobre os explain
elementos de resposta, consulte Explicar resultados.