mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-15 13:53:50 +01:00
Update users table in a batched manner
This commit is contained in:
parent
c22a3f37a9
commit
9669a99d1a
1 changed files with 13 additions and 8 deletions
|
@ -52,12 +52,17 @@ def run_upgrade(cur, database_engine, config, *args, **kwargs):
|
||||||
" service (IDs %s and %s); assigning arbitrarily to %s" %
|
" service (IDs %s and %s); assigning arbitrarily to %s" %
|
||||||
(user_id, owned[user_id], appservice.id, owned[user_id])
|
(user_id, owned[user_id], appservice.id, owned[user_id])
|
||||||
)
|
)
|
||||||
owned[user_id] = appservice.id
|
owned.setdefault(appservice.id, []).append(user_id)
|
||||||
|
|
||||||
for user_id, as_id in owned.items():
|
for as_id, user_ids in owned.items():
|
||||||
cur.execute(
|
n = 100
|
||||||
database_engine.convert_param_style(
|
user_chunks = (user_ids[i:i + 100] for i in xrange(0, len(user_ids), n))
|
||||||
"UPDATE users SET appservice_id = ? WHERE name = ?"
|
for chunk in user_chunks:
|
||||||
),
|
cur.execute(
|
||||||
(as_id, user_id)
|
database_engine.convert_param_style(
|
||||||
)
|
"UPDATE users SET appservice_id = ? WHERE name IN (%s)" % (
|
||||||
|
",".join("?" for _ in chunk),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
[as_id] + chunk
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in a new issue