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

129
Vistas
Postgres querying related performance question? I am querying from three different tables and merging result

I am creating an API for my Instagram clone app. I am using a postgres database with knexjs.

I have four tables for my app i.e. users, posts and likes.

I am building a profile page where user info is displayed. Profile page will display info from all the tables.

My question is whether making five separate queries to the database affect loading times of the profile page? I will be making Count, group by etc. queries that can not be merged or joined together.

Or is there any other alternative that won't affect the performance or the loading times?

Here is my route code: -

router.get('/:id', async (req, res) => {
    const userID = req.params.id;

    //Get the profile info from the db
    const profile = await getUserInfo(userID);
    
    if (profile.length === 0) {
        return res.json({
            errors: "No user found!"
        })
    }

    //Get last 9 created post ordered by creation date in DESC order
    const posts = await getUserPosts(userID)
    //Get posts count 
    const count = await getUserPostCount(userID)

    return res.json({
        profile: profile[0],
        posts,
        postCount: count[0].count
    }).status(201);
})

You can see there are three constants profile, posts and count which are making individual queries. Is that okay?

My full source code is here: - https://github.com/ajaybirbal/photogram-backend/blob/main/routes/profile.js

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