From d6a6821303cc0e4b3aa8cfb01830bcf44a821c92 Mon Sep 17 00:00:00 2001 From: rllola Date: Wed, 17 Jan 2024 13:16:57 +0100 Subject: [PATCH 1/2] remove foreign key constraint to speed up things and remove missing fk errors --- src/database.rs | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/src/database.rs b/src/database.rs index 9d225f8..a01582d 100644 --- a/src/database.rs +++ b/src/database.rs @@ -541,7 +541,7 @@ impl Database { /// Save all the transactions in txs, it is up to the caller to /// call sqlx_tx.commit().await?; for the changes to take place in /// database. - #[instrument(skip(txs, block_id, sqlx_tx, checksums_map, block_height, network))] + #[instrument(skip(block_id, sqlx_tx, checksums_map, block_height, network))] async fn save_transactions<'a>( txs: &Vec>, block_id: &[u8], @@ -1023,16 +1023,6 @@ impl Database { .execute(&*self.pool) .await?; - query( - format!( - "ALTER TABLE {0}.tx_transfer ADD CONSTRAINT fk_tx_id FOREIGN KEY (tx_id) REFERENCES {0}.transactions (hash);", - self.network - ) - .as_str(), - ) - .execute(&*self.pool) - .await?; - query( format!( "CREATE INDEX x_source_transfer ON {}.tx_transfer (source);", @@ -1063,16 +1053,6 @@ impl Database { .execute(&*self.pool) .await?; - query( - format!( - "ALTER TABLE {0}.tx_bond ADD CONSTRAINT fk_tx_id FOREIGN KEY (tx_id) REFERENCES {0}.transactions (hash);", - self.network - ) - .as_str(), - ) - .execute(&*self.pool) - .await?; - query( format!( "ALTER TABLE {}.tx_bridge_pool ADD CONSTRAINT pk_tx_id_bridge PRIMARY KEY (tx_id);", @@ -1083,16 +1063,6 @@ impl Database { .execute(&*self.pool) .await?; - query( - format!( - "ALTER TABLE {0}.tx_bridge_pool ADD CONSTRAINT fk_tx_id FOREIGN KEY (tx_id) REFERENCES {0}.transactions (hash);", - self.network - ) - .as_str(), - ) - .execute(&*self.pool) - .await?; - query( format!( "CREATE INDEX x_validator_bond ON {}.tx_bond (validator);", From 1f5d4d817987dfdb6b27aeaad6fed28e1e56231d Mon Sep 17 00:00:00 2001 From: rllola Date: Wed, 17 Jan 2024 13:21:39 +0100 Subject: [PATCH 2/2] skip txs and show block height in log --- src/database.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/database.rs b/src/database.rs index a01582d..290f922 100644 --- a/src/database.rs +++ b/src/database.rs @@ -541,7 +541,7 @@ impl Database { /// Save all the transactions in txs, it is up to the caller to /// call sqlx_tx.commit().await?; for the changes to take place in /// database. - #[instrument(skip(block_id, sqlx_tx, checksums_map, block_height, network))] + #[instrument(skip(txs, block_id, sqlx_tx, checksums_map, network))] async fn save_transactions<'a>( txs: &Vec>, block_id: &[u8],