1
0

Add some clarifications to README.md in the database schema directory. (#6615)

* commit '4fb5f4d0c':
  Add some clarifications to README.md in the database schema directory. (#6615)
  Minor perf fixes to `get_auth_chain_ids`.
This commit is contained in:
Andrew Morgan
2020-03-24 13:16:00 +00:00
5 changed files with 23 additions and 15 deletions

1
changelog.d/6615.misc Normal file
View File

@@ -0,0 +1 @@
Add some clarifications to `README.md` in the database schema directory.

1
changelog.d/6954.misc Normal file
View File

@@ -0,0 +1 @@
Minor perf fixes to `get_auth_chain_ids`.

View File

@@ -16,7 +16,6 @@ import itertools
import logging
from typing import List, Optional, Set
from six.moves import range
from six.moves.queue import Empty, PriorityQueue
from twisted.internet import defer
@@ -28,6 +27,7 @@ from synapse.storage.data_stores.main.events_worker import EventsWorkerStore
from synapse.storage.data_stores.main.signatures import SignatureWorkerStore
from synapse.storage.database import Database
from synapse.util.caches.descriptors import cached
from synapse.util.iterutils import batch_iter
logger = logging.getLogger(__name__)
@@ -88,14 +88,12 @@ class EventFederationWorkerStore(EventsWorkerStore, SignatureWorkerStore, SQLBas
front = set(event_ids)
while front:
new_front = set()
front_list = list(front)
chunks = [front_list[x : x + 100] for x in range(0, len(front), 100)]
for chunk in chunks:
for chunk in batch_iter(front, 100):
clause, args = make_in_list_sql_clause(
txn.database_engine, "event_id", chunk
)
txn.execute(base_sql + clause, list(args))
new_front.update([r[0] for r in txn])
txn.execute(base_sql + clause, args)
new_front.update(r[0] for r in txn)
new_front -= ignore_events
new_front -= results

View File

@@ -1,13 +1,21 @@
# Building full schema dumps
# Synapse Database Schemas
These schemas need to be made from a database that has had all background updates run.
These schemas are used as a basis to create brand new Synapse databases, on both
SQLite3 and Postgres.
To do so, use `scripts-dev/make_full_schema.sh`. This will produce
`full.sql.postgres ` and `full.sql.sqlite` files.
## Building full schema dumps
If you want to recreate these schemas, they need to be made from a database that
has had all background updates run.
To do so, use `scripts-dev/make_full_schema.sh`. This will produce new
`full.sql.postgres ` and `full.sql.sqlite` files.
Ensure postgres is installed and your user has the ability to run bash commands
such as `createdb`.
such as `createdb`, then call
```
./scripts-dev/make_full_schema.sh -p postgres_username -o output_dir/
```
./scripts-dev/make_full_schema.sh -p postgres_username -o output_dir/
There are currently two folders with full-schema snapshots. `16` is a snapshot
from 2015, for historical reference. The other contains the most recent full
schema snapshot.

View File

@@ -1504,7 +1504,7 @@ class Database(object):
def make_in_list_sql_clause(
database_engine, column: str, iterable: Iterable
) -> Tuple[str, Iterable]:
) -> Tuple[str, list]:
"""Returns an SQL clause that checks the given column is in the iterable.
On SQLite this expands to `column IN (?, ?, ...)`, whereas on Postgres