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:
Min Idzelis 2025-07-15 12:23:41 -04:00 committed by GitHub
parent eca54871d0
commit 68f249bc03
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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) {