Skip to content

Commit 5eb3894

Browse files
committed
Avoid unnecessary overhead during connection reset
UNLISTEN is now available in Hot Standby mode in all supported PostgreSQL versions, therefore there's no reason anymore to wrap it in DO block. This should significantly speed up connection reset.
1 parent 0dd636f commit 5eb3894

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

asyncpg/connection.py

+1-10
Original file line numberDiff line numberDiff line change
@@ -1501,16 +1501,7 @@ def _get_reset_query(self):
15011501
if caps.sql_close_all:
15021502
_reset_query.append('CLOSE ALL;')
15031503
if caps.notifications and caps.plpgsql:
1504-
_reset_query.append('''
1505-
DO $$
1506-
BEGIN
1507-
PERFORM * FROM pg_listening_channels() LIMIT 1;
1508-
IF FOUND THEN
1509-
UNLISTEN *;
1510-
END IF;
1511-
END;
1512-
$$;
1513-
''')
1504+
_reset_query.append('UNLISTEN *;')
15141505
if caps.sql_reset:
15151506
_reset_query.append('RESET ALL;')
15161507

0 commit comments

Comments
 (0)