Para agentes de IA: hay un índice de documentación disponible en https://www.mongodb.com/es/docs/llms.txt — versiones en markdown de todas las páginas están disponibles agregando .md a cualquier ruta URL.
Make the MongoDB docs better! We value your opinion. Share your feedback for a chance to win $100.
MongoDB Branding Shape
Click Here!
Docs Menu

Paraleliza la ejecución de consultas en todos los segmentos

La opción concurrent permite el paralelismo entre query. En este modo, MongoDB Search utiliza más recursos, pero mejora la latencia de cada query individual. Esta funcionalidad solo está disponible para nodos de búsqueda dedicados.

When you run queries with the concurrent option, MongoDB Search doesn't guarantee that each query executes concurrently. For example, when too many concurrent queries are queued, MongoDB Search might fallback to single-threaded execution.

concurrent tiene la siguiente sintaxis:

{
"$searchMeta"|"$search": {
"index": "<index name>", // optional, defaults to "default"
"<operator>": {
<operator-specifications>
},
"concurrent": true | false,
...
}
}

The concurrent boolean option allows you to request MongoDB Search to parallelize query execution across segments, which often improves the response time. You can set one of the following values for the concurrent option:

  • true - para solicitar que MongoDB Search ejecute la query con múltiples subprocesos

  • false - para ejecutar la query en un solo hilo (por defecto)

MongoDB Search te permite controlar este comportamiento query por query para permitir la ejecución simultánea solo de queries intensas y de larga duración, lo que minimiza la contención y mejora el rendimiento de la query en general. La ejecución concurrente es especialmente eficiente en grandes conjuntos de datos, ya que hay una mayor cantidad de segmentos.

MongoDB Search runs a concurrent query on multiple threads, so the query completes faster. But the query consumes more CPU on your Search Nodes while it runs. Enabling the concurrent option for high-volume or short-running queries can saturate the CPU on your Search Nodes and reduce overall query throughput. To limit the impact on CPU, enable the concurrent option only for the heavy and long-running queries that benefit from lower latency.

To measure the CPU cost of an individual query, run the query with explain and review the userTimeMs, systemTimeMs, and maxReportingThreads fields in the resourceUsage document.

To monitor CPU usage across your deployment, view the Atlas cluster metrics and the Review MongoDB Search Metrics. Atlas can also trigger MongoDB Search alerts that measure the amount of CPU that MongoDB Search processes use. If CPU usage approaches the limits of acceptable performance, scale your Search Nodes vertically or horizontally. To learn more, see Tips for Sizing and Scaling Search Nodes.

Considera la siguiente query con la colección sample_mflix.movies en los datos de muestra. La consulta indica una búsqueda simultánea de películas que contienen el término new york en el title.

1db.movies.aggregate([
2 {
3 "$search": {
4 "text": {
5 "path": "title",
6 "query": "new york"
7 },
8 "concurrent": true
9 }
10 }
11])