]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
perf(pool): replace SELECT 1 with an empty query
authorEyal Halpern Shalev <eyalsh@gmail.com>
Mon, 15 Apr 2024 23:09:45 +0000 (02:09 +0300)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 8 May 2024 16:50:19 +0000 (18:50 +0200)
psycopg_pool/psycopg_pool/pool.py
psycopg_pool/psycopg_pool/pool_async.py

index 2d17f5ff179c9612bcdfd6bdb3f7dd6f167ecd97..96a97ff20583ca87d63e048802231c1e71ddec66 100644 (file)
@@ -537,11 +537,11 @@ class ConnectionPool(Generic[CT], BasePool):
         for instance as `!check` callback when a pool is created.
         """
         if conn.autocommit:
-            conn.execute("SELECT 1")
+            conn.execute("--ping")
         else:
             conn.autocommit = True
             try:
-                conn.execute("SELECT 1")
+                conn.execute("--ping")
             finally:
                 conn.autocommit = False
 
index a12f33c3565467f29bf6a53bf76ac297a985c236..0a6ad529cb33cd42dab93929e0471e6ed2035919 100644 (file)
@@ -569,7 +569,7 @@ class AsyncConnectionPool(Generic[ACT], BasePool):
         for instance as `!check` callback when a pool is created.
         """
         if conn.autocommit:
-            await conn.execute("SELECT 1")
+            await conn.execute("--ping")
         else:
             if True:  # ASYNC
                 # NOTE: with Psycopg 3.2 we could use conn.set_autocommit() in
@@ -577,13 +577,13 @@ class AsyncConnectionPool(Generic[ACT], BasePool):
                 # previous versions too.
                 await conn.set_autocommit(True)
                 try:
-                    await conn.execute("SELECT 1")
+                    await conn.execute("--ping")
                 finally:
                     await conn.set_autocommit(False)
             else:
                 conn.autocommit = True
                 try:
-                    conn.execute("SELECT 1")
+                    conn.execute("--ping")
                 finally:
                     conn.autocommit = False