Skip to content

Commit 3bc2032

Browse files
committed
store: Analyze tables earlier during copying
Analyzing earlier makes it so that Postgres has statistics when rewinding the subgraph
1 parent c1011ee commit 3bc2032

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

store/postgres/src/deployment_store.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,6 +1553,12 @@ impl DeploymentStore {
15531553

15541554
catalog::copy_account_like(conn, &src.site, &dst.site)?;
15551555

1556+
// Analyze all tables for this deployment
1557+
info!(logger, "Analyzing all {} tables", dst.tables.len());
1558+
for entity_name in dst.tables.keys() {
1559+
self.analyze_with_conn(site.cheap_clone(), entity_name.as_str(), conn)?;
1560+
}
1561+
15561562
// Rewind the subgraph so that entity versions that are
15571563
// clamped in the future (beyond `block`) become valid for
15581564
// all blocks after `block`. `revert_block` gets rid of
@@ -1563,6 +1569,7 @@ impl DeploymentStore {
15631569
.number
15641570
.checked_add(1)
15651571
.expect("block numbers fit into an i32");
1572+
info!(logger, "Rewinding to block {}", block.number);
15661573
let count = dst.revert_block(conn, block_to_revert)?;
15671574
deployment::update_entity_count(conn, &dst.site, count)?;
15681575

@@ -1575,11 +1582,6 @@ impl DeploymentStore {
15751582
src_deployment.manifest.history_blocks,
15761583
)?;
15771584

1578-
// Analyze all tables for this deployment
1579-
for entity_name in dst.tables.keys() {
1580-
self.analyze_with_conn(site.cheap_clone(), entity_name.as_str(), conn)?;
1581-
}
1582-
15831585
// The `earliest_block` for `src` might have changed while
15841586
// we did the copy if `src` was pruned while we copied;
15851587
// adjusting it very late in the copy process ensures that

0 commit comments

Comments
 (0)