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... Apr 17 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
    Apr 17 at 14:16
  • @jjanes, please verify after I added the code snippet if you can Apr 18 at 9:25


Your Answer

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

Browse other questions tagged or ask your own question.