我有一个多次使用psycopg2的脚本。大约一个星期以来,它在代码的一个部分执行我的查询时非常慢,而在另一个部分则执行得很好。这种情况以前没有发生过--我以前多次运行这段代码,都没有这种问题。
我试图理解为什么在这种特殊情况下,执行速度如此之慢(大约2秒),我可以做什么来更彻底地检查它?
-Win10
-Python 3.7.4
-Psycopg2 2.8.3
->All run via PyCharm
-PostgreSQL 9.2
What I tried:
-Running same querty in pgAdmin -> works fine and fast
-Connection ->switched from Wi-Fi to LAN, no result
-Checked code for actual moments when the code becomes slow -> slows down on execute statement.
-检查了网络,但在搜索条件下只发现了与fetchall()有关的问题,涉及速度慢和psycopg。
-Checked win10 updates if these do not cause some problems but it seems that's not the case -> code runs fine in other parts of the script.
conn = psycopg2.connect(host=adres, port=port, database="database", user=log, password=pas)
cur = conn.cursor()
query = """SELECT string_agg(pn.full_name,','),
string_agg(ms.wrong_fullname,',')
FROM names as pn
LEFT JOIN name_misspellings as ms on (ms.id_person_name = pn.id)
WHERE pn.id_human = 9220478"""