]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
refactor: send only once per stream
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 1 May 2022 12:35:02 +0000 (14:35 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 2 May 2022 00:07:50 +0000 (02:07 +0200)
No need to do it at every row, probably entirely wrong. However this is
not the cause of the slowness reported in #286.

psycopg/psycopg/cursor.py

index c613f43111b93df5acbf5e1cc3b719186adb55d3..2c127587d6e4c2ff74513f3b8347cd534d4b6623 100644 (file)
@@ -281,9 +281,9 @@ class BaseCursor(Generic[ConnectionType, Row]):
         self._execute_send(pgq, binary=binary, no_pqexec=True)
         self._pgconn.set_single_row_mode()
         self._last_query = query
+        yield from send(self._pgconn)
 
     def _stream_fetchone_gen(self, first: bool) -> PQGen[Optional["PGresult"]]:
-        yield from send(self._pgconn)
         res = yield from fetch(self._pgconn)
         if res is None:
             return None