Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/op-sqlite-parallel-read-connections.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@powersync/react-native': patch
---

Configure the op-sqlite read connections concurrently during initialization instead of one after another, reducing time to database readiness on cold start.
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,15 @@ export class OPSQLiteDBAdapter extends DBAdapter {
}
}

const underlyingReadConnections = [];
for (let i = 0; i < READ_CONNECTIONS; i++) {
const conn = await this.openConnection(true, dbFilename);
for (let statement of baseStatements) {
await conn.execute(statement);
}
underlyingReadConnections.push(conn);
}
const underlyingReadConnections = await Promise.all(
Array.from({ length: READ_CONNECTIONS }, async () => {
const conn = await this.openConnection(true, dbFilename);
for (const statement of baseStatements) {
await conn.execute(statement);
}
return conn;
})
);

this.writeConnection = new Semaphore([underlyingWriteConnection]);
this.readConnections = new Semaphore(underlyingReadConnections);
Expand Down
Loading