When getting a query result from a remote server, does the execution of the query transmit the result to the local machine, or is it buffered on remote and only downloaded when fetching the result?

Here is how the cursor is defined:

con = psycopg2.connect(f"host='{host}' port='{port}' dbname='{DB}' user='{user}' password='{pw}'")

cur = con.cursor()
  • I am trying to separate the download speed from the query execution time to see which is more time-consuming... Commented Apr 17, 2023 at 8:46
  • 1
    With psycopg2, it depends on how the cursor is defined. You should show the code. The most common way, the execute retrieves all the results into local memory managed by C, and fetch just hands them over to python.
    – jjanes
    Commented Apr 17, 2023 at 14:16
  • @jjanes, please verify after I added the code snippet if you can Commented Apr 18, 2023 at 9:25


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.