Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

175
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!