You've already forked joplin
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:
@@ -166,7 +166,7 @@ By default the server supports SQLite for development, so nothing needs to be se
|
|||||||
|
|
||||||
### PostgreSQL
|
### 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
|
## Starting the server
|
||||||
|
|
||||||
|
|||||||
@@ -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');
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user