Closed kamelzcs closed 9 years ago
Could you run another test with plain sync psycopg2 (i.e. without momoko) and compare results?
It is sync psycopg2 not async psycopg2?
Yes, just create regular psycopg2
connection beforehand and use it to query database in your get
request. Don't even import momoko.
There should be something wrong. The difference is really huge.
Can you post the results?, including your test code?
I updated it in the first post
Yes, the difference is huge indeed. I'll look at this next week.
Also can you post python, psycopg2 and momoko versions you are using?
After the commit
is used, the psycopg2
becomes slow as well
class SingleQueryHandler(BaseHandler):
@gen.coroutine
def get(self):
try:
cursor = self.db.cursor()
cursor.execute('INSERT INTO "member" ("membername", "birthday") VALUES (%s, %s) RETURNING ID', ('123', '2014/12/17'))
self.db.commit()
self.write('Query results: %s<br>\n' % cursor.fetchall())
except Exception as error:
self.write(str(error))
self.finish()
[I 141225 17:18:52 web:1811] 200 GET /query (127.0.0.1) 19.35ms
[I 141225 17:18:53 web:1811] 200 GET /query (127.0.0.1) 16.96ms
[I 141225 17:18:55 web:1811] 200 GET /query (127.0.0.1) 402.65ms
[I 141225 17:18:58 web:1811] 200 GET /query (127.0.0.1) 2317.28ms
[I 141225 17:19:02 web:1811] 200 GET /query (127.0.0.1) 1396.84ms
[I 141225 17:19:03 web:1811] 200 GET /query (127.0.0.1) 33.61ms
[I 141225 17:19:04 web:1811] 200 GET /query (127.0.0.1) 444.74ms
[I 141225 17:19:05 web:1811] 200 GET /query (127.0.0.1) 15.53ms
[I 141225 17:19:06 web:1811] 200 GET /query (127.0.0.1) 18.40ms
[I 141225 17:19:07 web:1811] 200 GET /query (127.0.0.1) 12.16ms
[I 141225 17:19:11 web:1811] 200 GET /query (127.0.0.1) 3081.28ms
Nice catch. I guess then its not momoko specific issue. I suggest posting to psycopg mailing list. It also would be nice if you post link to the mail thread here later.
Actually it is the Pgadmin3
log to blame. After I shut it down, everything works on the fly!
Thanks for your time!
Python
:2.7.6
Tornado
:4.0.2
Psycopg2
:2.5.4
Changed the
SingleQueryHandler
in examplesThis is a successive click on the
/query
link. It seems the respond time is very unstable, such simple insert query could lead to at most2445.17ms
delay.For sync
psycopg2
, the code is as follows:The result is as follows:
The difference is very huge.
After the commit is used, the
psycopg2
becomes slow as well