|
@@ -9,7 +9,7 @@ import asyncpg
|
|
|
import jinja2
|
|
|
import orjson
|
|
|
|
|
|
-PG_POOL_SIZE = 2
|
|
|
+PG_POOL_SIZE = 4
|
|
|
|
|
|
|
|
|
class NoResetConnection(asyncpg.Connection):
|
|
@@ -109,8 +109,7 @@ async def route_queries(scope, receive, send):
|
|
|
worlds = []
|
|
|
|
|
|
async with pool.acquire() as connection:
|
|
|
- statement = await connection.prepare(SQL_SELECT)
|
|
|
- rows = await statement.fetchmany([(v,) for v in row_ids])
|
|
|
+ rows = await connection.fetchmany(SQL_SELECT, [(v,) for v in row_ids])
|
|
|
|
|
|
worlds = [{'id': row_id, 'randomNumber': number[0]} for row_id, number in zip(row_ids, rows)]
|
|
|
await send(JSON_RESPONSE)
|
|
@@ -145,8 +144,7 @@ async def route_updates(scope, receive, send):
|
|
|
worlds = [{'id': row_id, 'randomNumber': number} for row_id, number in updates]
|
|
|
|
|
|
async with pool.acquire() as connection:
|
|
|
- statement = await connection.prepare(SQL_SELECT)
|
|
|
- await statement.executemany([(i[0],) for i in updates])
|
|
|
+ await connection.executemany(SQL_SELECT, [(i[0],) for i in updates])
|
|
|
await connection.executemany(SQL_UPDATE, updates)
|
|
|
|
|
|
await send(JSON_RESPONSE)
|