Skip to content
This repository was archived by the owner on Mar 14, 2025. It is now read-only.

Commit b9b2448

Browse files
committed
fix: standardize insert batch size
1 parent 4a81f37 commit b9b2448

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/pg/pg-store.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import {
4141

4242
export const MIGRATIONS_DIR = path.join(__dirname, '../../migrations');
4343
export const ORDINALS_GENESIS_BLOCK = 767430;
44+
const INSERT_BATCH_SIZE = 4000;
4445

4546
type InscriptionIdentifier = { genesis_id: string } | { number: number };
4647

@@ -133,7 +134,7 @@ export class PgStore extends BasePgStore {
133134
currentBlockHeight: currentBlockHeight,
134135
newBlockHeight: event.block_identifier.index,
135136
});
136-
for (const writeChunk of batchIterate(writes, 4000))
137+
for (const writeChunk of batchIterate(writes, INSERT_BATCH_SIZE))
137138
await this.insertInscriptions(writeChunk);
138139
updatedBlockHeightMin = Math.min(updatedBlockHeightMin, event.block_identifier.index);
139140
logger.info(
@@ -548,7 +549,7 @@ export class PgStore extends BasePgStore {
548549
updated_at = NOW()
549550
`;
550551
const pointers: DbLocationPointerInsert[] = [];
551-
for (const batch of batchIterate(locationInserts, 8000))
552+
for (const batch of batchIterate(locationInserts, INSERT_BATCH_SIZE))
552553
pointers.push(
553554
...(await sql<DbLocationPointerInsert[]>`
554555
INSERT INTO locations ${sql(batch)}
@@ -571,7 +572,7 @@ export class PgStore extends BasePgStore {
571572
SET updated_at = NOW()
572573
WHERE sat_ordinal IN ${sql(transferredOrdinalNumbers)}
573574
`;
574-
for (const batch of batchIterate(pointers, 8000))
575+
for (const batch of batchIterate(pointers, INSERT_BATCH_SIZE))
575576
await this.updateInscriptionLocationPointers(batch);
576577
for (const reveal of reveals) {
577578
const action =

0 commit comments

Comments
 (0)