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

264
Vistas
API slow - fast in MongoDb but when in API its much slower, maybe due to RegExp

I've noticed my API is slow. To return restaurants when searching on towns is around 4 seconds average, (even if there are only 10 results). Same search (without RegExp), direct on Mongo Atlas is a tenth of a second. Here is my javascript code. I'm using Express, Mongoose and RegExp in my js. Is there any way to speed this up pls? :

// Route to return all restaurants matching the searched name, returning all fields, using a collection that has collation//
app.route("/restaurants/:restaurantName")

  .get(function(req, res) {
    let partialToMatch = new RegExp(req.params.restaurantName, 'i');
    Restaurant.find({
      BusinessName: partialToMatch
    }, null, {
      limit: 25
    }, function(err, foundRestaurant) {
      if (foundRestaurant) {
        res.send(foundRestaurant)
      } else {
        res.send("No restaurants matching that title was found.");
      }
    });
  });
about 4 years ago · Juan Pablo Isaza
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