Skip to content

Commit

Permalink
Merge pull request #41 from vulcanize/release-v3.0.1
Browse files Browse the repository at this point in the history
disable and renable indexes correctly
  • Loading branch information
i-norden authored Jan 11, 2022
2 parents 35a1ba7 + ae1a6e9 commit 6612eda
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 33 deletions.
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,11 @@ rollback_to: $(GOOSE) checkmigration checkdbvars
.PHONY: `rollback_pre_batch_set`
rollback_pre_batch_set: $(GOOSE) checkdbvars
$(GOOSE) -dir db/pre_batch_processing_migrations postgres "$(CONNECT_STRING)" down
pg_dump -O -s $(CONNECT_STRING) > schema.sql

## Rollback post_batch_set
.PHONY: rollback_post_batch_set
rollback_post_batch_set: $(GOOSE) checkdbvars
$(GOOSE) -dir db/post_batch_processing_migrations postgres "$(CONNECT_STRING)" down
pg_dump -O -s $(CONNECT_STRING) > schema.sql

## Apply the next up migration
.PHONY: migrate_up_by_one
Expand Down
20 changes: 10 additions & 10 deletions db/post_batch_processing_migrations/00018_create_log_indexes.sql
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
-- +goose Up
CREATE INDEX log_mh_index_index ON eth.log_cids USING btree (leaf_mh_key);
CREATE INDEX log_mh_index ON eth.log_cids USING btree (leaf_mh_key);
CREATE INDEX block_number_index ON eth.header_cids USING brin (block_number);
CREATE INDEX header_hash_index ON eth.header_cids USING btree (block_hash);
CREATE INDEX tx_header_hash_index ON eth.transaction_cids USING btree (header_id);
CREATE INDEX transaction_hash_index ON eth.transaction_cids USING btree (tx_hash);
CREATE INDEX log_tx_hash_index ON eth.log_cids USING btree (rct_id);
CREATE INDEX header_block_hash_index ON eth.header_cids USING btree (block_hash);
CREATE INDEX tx_header_id_index ON eth.transaction_cids USING btree (header_id);
CREATE INDEX tx_tx_hash_index ON eth.transaction_cids USING btree (tx_hash);
CREATE INDEX log_cids_index ON eth.log_cids USING btree (rct_id, index);

-- +goose Down
DROP INDEX eth.log_tx_hash_index;
DROP INDEX eth.transaction_hash_index;
DROP INDEX eth.tx_header_hash_index;
DROP INDEX eth.header_hash_index;
DROP INDEX eth.log_cids_index;
DROP INDEX eth.tx_tx_hash_index;
DROP INDEX eth.tx_header_id_index;
DROP INDEX eth.header_block_hash_index;
DROP INDEX eth.block_number_index;
DROP INDEX eth.log_mh_index_index;
DROP INDEX eth.log_mh_index;
45 changes: 45 additions & 0 deletions db/post_batch_processing_migrations/00019_disable_log_indexes.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
-- +goose Up
UPDATE pg_index
SET indisready=false
WHERE indrelid = (
SELECT oid
FROM pg_class
WHERE relname='eth.log_cids'
);
UPDATE pg_index
SET indisready=false
WHERE indrelid = (
SELECT oid
FROM pg_class
WHERE relname='eth.transaction_cids'
);
UPDATE pg_index
SET indisready=false
WHERE indrelid = (
SELECT oid
FROM pg_class
WHERE relname='eth.header_cids'
);

-- +goose Down
UPDATE pg_index
SET indisready=true
WHERE indrelid = (
SELECT oid
FROM pg_class
WHERE relname='eth.header_cids'
);
UPDATE pg_index
SET indisready=true
WHERE indrelid = (
SELECT oid
FROM pg_class
WHERE relname='eth.transaction_cids'
);
UPDATE pg_index
SET indisready=true
WHERE indrelid = (
SELECT oid
FROM pg_class
WHERE relname='eth.log_cids'
);
15 changes: 0 additions & 15 deletions db/post_batch_processing_migrations/00019_remove_log_indexes.sql

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
-- +goose Up
UPDATE pg_index
SET indisready=true
WHERE indrelid = (
SELECT oid
FROM pg_class
WHERE relname='eth.header_cids'
);
UPDATE pg_index
SET indisready=true
WHERE indrelid = (
SELECT oid
FROM pg_class
WHERE relname='eth.transaction_cids'
);
UPDATE pg_index
SET indisready=true
WHERE indrelid = (
SELECT oid
FROM pg_class
WHERE relname='eth.log_cids'
);
REINDEX TABLE eth.header_cids;
REINDEX TABLE eth.transaction_cids;
REINDEX TABLE eth.log_cids;

-- +goose Down
UPDATE pg_index
SET indisready=false
WHERE indrelid = (
SELECT oid
FROM pg_class
WHERE relname='eth.log_cids'
);
UPDATE pg_index
SET indisready=false
WHERE indrelid = (
SELECT oid
FROM pg_class
WHERE relname='eth.transaction_cids'
);
UPDATE pg_index
SET indisready=false
WHERE indrelid = (
SELECT oid
FROM pg_class
WHERE relname='eth.header_cids'
);
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
-- +goose Up
-- header indexes
CREATE INDEX block_number_index ON eth.header_cids USING brin (block_number);
CREATE INDEX header_cid_index ON eth.header_cids USING btree (cid);
CREATE INDEX header_mh_index ON eth.header_cids USING btree (mh_key);
CREATE INDEX state_root_index ON eth.header_cids USING btree (state_root);
Expand All @@ -10,7 +9,6 @@ CREATE INDEX timestamp_index ON eth.header_cids USING brin (timestamp);
CREATE INDEX uncle_header_id_index ON eth.uncle_cids USING btree (header_id);

-- transaction indexes
CREATE INDEX tx_header_id_index ON eth.transaction_cids USING btree (header_id);
CREATE INDEX tx_cid_index ON eth.transaction_cids USING btree (cid);
CREATE INDEX tx_mh_index ON eth.transaction_cids USING btree (mh_key);
CREATE INDEX tx_dst_index ON eth.transaction_cids USING btree (dst);
Expand Down Expand Up @@ -46,7 +44,6 @@ CREATE INDEX access_list_element_address_index ON eth.access_list_elements USING
CREATE INDEX access_list_storage_keys_index ON eth.access_list_elements USING gin (storage_keys);

-- log indexes
CREATE INDEX log_mh_index ON eth.log_cids USING btree (leaf_mh_key);
CREATE INDEX log_cid_index ON eth.log_cids USING btree (leaf_cid);
CREATE INDEX log_address_index ON eth.log_cids USING btree (address);
CREATE INDEX log_topic0_index ON eth.log_cids USING btree (topic0);
Expand All @@ -62,7 +59,6 @@ DROP INDEX eth.log_topic1_index;
DROP INDEX eth.log_topic0_index;
DROP INDEX eth.log_address_index;
DROP INDEX eth.log_cid_index;
DROP INDEX eth.log_mh_index;

-- access list indexes
DROP INDEX eth.access_list_storage_keys_index;
Expand Down Expand Up @@ -98,7 +94,6 @@ DROP INDEX eth.tx_src_index;
DROP INDEX eth.tx_dst_index;
DROP INDEX eth.tx_mh_index;
DROP INDEX eth.tx_cid_index;
DROP INDEX eth.tx_header_id_index;

-- uncle indexes
DROP INDEX eth.uncle_header_id_index;
Expand All @@ -108,4 +103,3 @@ DROP INDEX eth.timestamp_index;
DROP INDEX eth.state_root_index;
DROP INDEX eth.header_mh_index;
DROP INDEX eth.header_cid_index;
DROP INDEX eth.block_number_index;

0 comments on commit 6612eda

Please sign in to comment.