Skip to content

Commit 106ed60

Browse files
committed
store: Clear the entity count when truncating a deployment
We used to count entities, but we know the result is 0 because all the tables we are counting are empty
1 parent ce85d3a commit 106ed60

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

store/postgres/src/deployment.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,17 +1249,12 @@ pub fn update_entity_count(
12491249
Ok(())
12501250
}
12511251

1252-
/// Set the deployment's entity count to whatever `full_count_query` produces
1253-
pub fn set_entity_count(
1254-
conn: &mut PgConnection,
1255-
site: &Site,
1256-
full_count_query: &str,
1257-
) -> Result<(), StoreError> {
1252+
/// Set the deployment's entity count back to `0`
1253+
pub fn clear_entity_count(conn: &mut PgConnection, site: &Site) -> Result<(), StoreError> {
12581254
use subgraph_deployment as d;
12591255

1260-
let full_count_query = format!("({})", full_count_query);
12611256
update(d::table.filter(d::id.eq(site.id)))
1262-
.set(d::entity_count.eq(sql(&full_count_query)))
1257+
.set(d::entity_count.eq(BigDecimal::from(0)))
12631258
.execute(conn)?;
12641259
Ok(())
12651260
}

store/postgres/src/deployment_store.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,7 @@ impl DeploymentStore {
13131313

13141314
let event = if truncate {
13151315
let event = layout.truncate_tables(conn)?;
1316-
deployment::set_entity_count(conn, site.as_ref(), layout.count_query.as_str())?;
1316+
deployment::clear_entity_count(conn, site.as_ref())?;
13171317
event
13181318
} else {
13191319
let (event, count) = layout.revert_block(conn, block)?;

0 commit comments

Comments
 (0)