Skip to content

Commit 102aa23

Browse files
kitogodmig
authored andcommitted
Avoid unnecessary overhead during connection reset (MagicStack#648)
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 c15d62a commit 102aa23

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
@@ -1540,16 +1540,7 @@ def _get_reset_query(self):
15401540
if caps.sql_close_all:
15411541
_reset_query.append('CLOSE ALL;')
15421542
if caps.notifications and caps.plpgsql:
1543-
_reset_query.append('''
1544-
DO $$
1545-
BEGIN
1546-
PERFORM * FROM pg_listening_channels() LIMIT 1;
1547-
IF FOUND THEN
1548-
UNLISTEN *;
1549-
END IF;
1550-
END;
1551-
$$;
1552-
''')
1543+
_reset_query.append('UNLISTEN *;')
15531544
if caps.sql_reset:
15541545
_reset_query.append('RESET ALL;')
15551546

0 commit comments

Comments
 (0)