Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

186
Vistas
Will I have to attach shard key with my query to get performance?

I am new to mongodb sharding. We know that we shard a database for scaling purpose. Where we need to use a sharding key so that the database distributing system can distribute data based on those key values. My question is - will I have to attach the sharding key with the query to avoid unnecessary query on other sharded db servers or does this work for mongodb sharding ?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

When your search is having the shard key index in the query , the mongodb sharded cluster routing service(mongos) will forward your query directly to the shard for which the query is addressed avoiding the "scatter-gather" request to all shards. This is because the mongos is caching the shard key index ranges and know in advance to which shard to address the request.

Moreover in specific write cases in mongodb version >=4.2 including the shard key in the query part is compulsory.

Also if your data is distributed between few shards sending broadcast requests is not an issue , but in case you have 100x shards you will need to wait for all 100 shards to search and reply to the mongos , so in general not using the shard key is a not scalable operation and need to be avoided whenever possible.

I hope this answer your question ...

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda