1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-26 22:41:17 +02:00

Server: Optimise delta sync queries by optimising the underlying SQL query

This commit is contained in:
Laurent Cozic
2025-02-19 18:59:03 +00:00
parent 914b5e230d
commit 4df0b9f851
2 changed files with 13 additions and 1 deletions

View File

@@ -166,7 +166,7 @@ By default the server supports SQLite for development, so nothing needs to be se
### PostgreSQL
To use Postgres, from the monorepo root, run `docker compose --file docker-compose.server-dev.yml up`, which will start the PostgreSQL database.
To use Postgres, from the monorepo root, run `docker compose --file docker-compose.db-dev.yml up`, which will start the PostgreSQL database.
## Starting the server

View File

@@ -0,0 +1,12 @@
import { DbConnection } from '../db';
export const up = async (db: DbConnection) => {
// This is another optimisation for the sub-query in ChangeModel::changesForUserQuery()
// which retrieves all the "update" (2) changes. We make it concurrent so that it doesn't
// lock this busy table while it's being created.
await db.raw('CREATE INDEX IF NOT EXISTS changes_type2_counter_idx ON changes (counter) WHERE type = 2');
};
export const down = async (db: DbConnection) => {
await db.raw('DROP INDEX changes_type2_counter_idx');
};