mirror of
https://github.com/immich-app/immich.git
synced 2025-07-31 15:08:44 -04:00
feat: improve geodata import speed (#19906)
chore(deps): update dependency vite to v7 (#19657) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Daniel Dietzler <mail@ddietzler.dev>
This commit is contained in:
parent
eca54871d0
commit
68f249bc03
@ -265,6 +265,9 @@ export class MapRepository {
|
|||||||
throw new Error(`Geodata file ${cities500} not found`);
|
throw new Error(`Geodata file ${cities500} not found`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.logger.log(`Starting geodata import`);
|
||||||
|
const startTime = performance.now();
|
||||||
|
|
||||||
const input = createReadStream(cities500, { highWaterMark: 512 * 1024 * 1024 });
|
const input = createReadStream(cities500, { highWaterMark: 512 * 1024 * 1024 });
|
||||||
let bufferGeodata = [];
|
let bufferGeodata = [];
|
||||||
const lineReader = readLine.createInterface({ input });
|
const lineReader = readLine.createInterface({ input });
|
||||||
@ -314,7 +317,20 @@ export class MapRepository {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.db.insertInto('geodata_places').values(bufferGeodata).execute();
|
if (bufferGeodata.length > 0) {
|
||||||
|
await this.db.insertInto('geodata_places').values(bufferGeodata).execute();
|
||||||
|
count += bufferGeodata.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.all(futures);
|
||||||
|
|
||||||
|
const duration = performance.now() - startTime;
|
||||||
|
const seconds = duration / 1000;
|
||||||
|
const recordsPerSecond = Math.round(count / seconds);
|
||||||
|
|
||||||
|
this.logger.log(
|
||||||
|
`Successfully imported ${count} geodata records in ${seconds.toFixed(2)}s (${recordsPerSecond} records/second)`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async loadAdmin(filePath: string) {
|
private async loadAdmin(filePath: string) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user