]> 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>
Sun, 1 May 2022 20:46:49 +0000 (22:46 +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 c32ef0309d8684cbfc4a5682a5da025af6221795..0e549e0844a4720ba742b9288775d1e3b45c874d 100644 (file)
@@ -340,9 +340,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