提高首次业务镜像批次效率 #60
@ -50,7 +50,10 @@ class BusinessMirrorSynchronizer
|
||||
);
|
||||
$cursor = is_array($state['cursor'] ?? null) ? $state['cursor'] : null;
|
||||
$highWatermark = is_array($state['high_watermark'] ?? null) ? $state['high_watermark'] : [];
|
||||
$batchSize = min(max($batchSize ?? (int) config('upstream_mirrors.table_sync.batch_size', 500), 1), 2000);
|
||||
// Routine runs keep the configured 500-row default. A larger explicit
|
||||
// batch is reserved for supervised first syncs so wide SQL Server views
|
||||
// need fewer repeated keyset scans without creating unbounded PHP arrays.
|
||||
$batchSize = min(max($batchSize ?? (int) config('upstream_mirrors.table_sync.batch_size', 500), 1), 5000);
|
||||
$maxBatches = max($maxBatches ?? (int) config('upstream_mirrors.table_sync.max_batches_per_run', 2), 0);
|
||||
$batches = 0;
|
||||
$rows = (int) ($state['last_upserted_rows'] ?? 0);
|
||||
|
||||
@ -146,6 +146,17 @@ class BusinessMirrorSynchronizerTest extends TestCase
|
||||
$this->assertSame([], $this->query->calls);
|
||||
}
|
||||
|
||||
public function test_supervised_full_sync_caps_explicit_batch_size_at_five_thousand(): void
|
||||
{
|
||||
$this->query->batches = [[
|
||||
['Id' => 1, 'updateTime' => '2026-08-14 10:00:00', 'displayName' => '一号', 'businessDate' => '2026-08-14'],
|
||||
]];
|
||||
|
||||
$this->synchronizer->sync('test.dbo.records', true, 50000, 1);
|
||||
|
||||
$this->assertStringContainsString('SELECT TOP (5000)', $this->query->calls[0]['sql']);
|
||||
}
|
||||
|
||||
public function test_full_sync_sanitizes_invalid_utf8_text_without_changing_valid_text(): void
|
||||
{
|
||||
$this->query->batches = [[
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user