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

176
Vistas
pd.read_sql has poor performance

I'm building an API that reads data from a table in PostgresQL, perform some transformations and return it.

However, when I try to run pd.read_sql("SELECT * FROM my_table", engine), it seems to take quite a few seconds.

On the contrary, when I try to read it from DBeaver, the query took less than a second to return the result.

May I get some advice to improve this? Ideally, I'm trying to make the API to return the result quicker and optimising this seems to be a good step.

Additional information: The table has around 3k records and 10 columsn.

Code:

def query_data():
    items = pd.read_sql("SELECT * FROM items", engine)

    return items.to_list()


@app.get("/get_data")
def get_data():
    t_1 = time()
    items = query_data()
    t_2 = time()
    print("t_2 - t_1: ", round(t_3 - t_2, 0), "s")
    return items
over 4 years ago · Santiago Trujillo
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