2021-08-29 18:55:44 +00:00
-- +goose Up
-- header indexes
2023-02-20 19:47:23 +00:00
CREATE INDEX header_block_number_index ON eth . header_cids USING btree ( block_number ) ;
2023-02-09 00:22:40 +00:00
CREATE UNIQUE INDEX header_cid_block_number_index ON eth . header_cids USING btree ( cid , block_number ) ;
2022-08-30 17:05:51 +00:00
CREATE INDEX state_root_index ON eth . header_cids USING btree ( state_root ) ;
2023-02-20 19:47:23 +00:00
CREATE INDEX timestamp_index ON eth . header_cids USING btree ( timestamp ) ;
2021-08-29 18:55:44 +00:00
2021-11-15 00:06:02 +00:00
-- uncle indexes
2023-02-20 19:47:23 +00:00
CREATE INDEX uncle_block_number_index ON eth . uncle_cids USING btree ( block_number ) ;
2023-04-18 06:55:37 +00:00
CREATE UNIQUE INDEX uncle_cid_block_number_index ON eth . uncle_cids USING btree ( cid , block_number , index ) ;
2021-11-15 00:06:02 +00:00
CREATE INDEX uncle_header_id_index ON eth . uncle_cids USING btree ( header_id ) ;
2021-08-29 18:55:44 +00:00
-- transaction indexes
2023-02-20 19:47:23 +00:00
CREATE INDEX tx_block_number_index ON eth . transaction_cids USING btree ( block_number ) ;
2022-08-30 17:05:51 +00:00
CREATE INDEX tx_header_id_index ON eth . transaction_cids USING btree ( header_id ) ;
2023-02-09 00:22:40 +00:00
CREATE INDEX tx_cid_block_number_index ON eth . transaction_cids USING btree ( cid , block_number ) ;
2022-08-30 17:05:51 +00:00
CREATE INDEX tx_dst_index ON eth . transaction_cids USING btree ( dst ) ;
CREATE INDEX tx_src_index ON eth . transaction_cids USING btree ( src ) ;
2021-08-29 18:55:44 +00:00
-- receipt indexes
2023-02-20 19:47:23 +00:00
CREATE INDEX rct_block_number_index ON eth . receipt_cids USING btree ( block_number ) ;
2022-08-30 17:05:51 +00:00
CREATE INDEX rct_header_id_index ON eth . receipt_cids USING btree ( header_id ) ;
2023-02-09 00:22:40 +00:00
CREATE INDEX rct_cid_block_number_index ON eth . receipt_cids USING btree ( cid , block_number ) ;
2022-08-30 17:05:51 +00:00
CREATE INDEX rct_contract_index ON eth . receipt_cids USING btree ( contract ) ;
2021-08-29 18:55:44 +00:00
-- state node indexes
2023-02-20 19:47:23 +00:00
CREATE INDEX state_block_number_index ON eth . state_cids USING btree ( block_number ) ;
2023-02-09 00:22:40 +00:00
CREATE INDEX state_cid_block_number_index ON eth . state_cids USING btree ( cid , block_number ) ;
2022-08-30 17:05:51 +00:00
CREATE INDEX state_header_id_index ON eth . state_cids USING btree ( header_id ) ;
2023-01-23 23:12:50 +00:00
CREATE INDEX state_removed_index ON eth . state_cids USING btree ( removed ) ;
CREATE INDEX state_code_hash_index ON eth . state_cids USING btree ( code_hash ) ; -- could be useful for e.g. selecting all the state accounts with the same contract bytecode deployed
2022-11-16 17:31:26 +00:00
CREATE INDEX state_leaf_key_block_number_index ON eth . state_cids ( state_leaf_key , block_number DESC ) ;
2021-09-10 15:12:54 +00:00
2021-08-29 18:55:44 +00:00
-- storage node indexes
2023-02-20 19:47:23 +00:00
CREATE INDEX storage_block_number_index ON eth . storage_cids USING btree ( block_number ) ;
2023-01-23 23:08:20 +00:00
CREATE INDEX storage_state_leaf_key_index ON eth . storage_cids USING btree ( state_leaf_key ) ;
2023-02-09 00:22:40 +00:00
CREATE INDEX storage_cid_block_number_index ON eth . storage_cids USING btree ( cid , block_number ) ;
2022-08-30 17:05:51 +00:00
CREATE INDEX storage_header_id_index ON eth . storage_cids USING btree ( header_id ) ;
2023-01-23 23:12:50 +00:00
CREATE INDEX storage_removed_index ON eth . storage_cids USING btree ( removed ) ;
2022-11-16 17:31:26 +00:00
CREATE INDEX storage_leaf_key_block_number_index ON eth . storage_cids ( storage_leaf_key , block_number DESC ) ;
2021-08-29 18:55:44 +00:00
2021-11-15 00:06:02 +00:00
-- log indexes
2023-02-20 19:47:23 +00:00
CREATE INDEX log_block_number_index ON eth . log_cids USING btree ( block_number ) ;
2022-08-30 17:05:51 +00:00
CREATE INDEX log_header_id_index ON eth . log_cids USING btree ( header_id ) ;
2023-02-09 00:22:40 +00:00
CREATE INDEX log_cid_block_number_index ON eth . log_cids USING btree ( cid , block_number ) ;
2022-08-30 17:05:51 +00:00
CREATE INDEX log_address_index ON eth . log_cids USING btree ( address ) ;
CREATE INDEX log_topic0_index ON eth . log_cids USING btree ( topic0 ) ;
CREATE INDEX log_topic1_index ON eth . log_cids USING btree ( topic1 ) ;
CREATE INDEX log_topic2_index ON eth . log_cids USING btree ( topic2 ) ;
CREATE INDEX log_topic3_index ON eth . log_cids USING btree ( topic3 ) ;
2021-11-15 00:06:02 +00:00
2021-08-29 18:55:44 +00:00
-- +goose Down
2021-11-15 00:06:02 +00:00
-- log indexes
DROP INDEX eth . log_topic3_index ;
DROP INDEX eth . log_topic2_index ;
DROP INDEX eth . log_topic1_index ;
DROP INDEX eth . log_topic0_index ;
DROP INDEX eth . log_address_index ;
2023-02-09 00:22:40 +00:00
DROP INDEX eth . log_cid_block_number_index ;
2022-07-07 10:51:06 +00:00
DROP INDEX eth . log_header_id_index ;
2022-03-15 21:06:13 +00:00
DROP INDEX eth . log_block_number_index ;
2021-11-15 00:06:02 +00:00
2021-08-29 18:55:44 +00:00
-- storage node indexes
2023-01-23 23:12:50 +00:00
DROP INDEX eth . storage_removed_index ;
2022-03-28 23:22:57 +00:00
DROP INDEX eth . storage_header_id_index ;
2023-02-09 00:22:40 +00:00
DROP INDEX eth . storage_cid_block_number_index ;
2023-01-23 23:08:20 +00:00
DROP INDEX eth . storage_state_leaf_key_index ;
2022-03-15 21:06:13 +00:00
DROP INDEX eth . storage_block_number_index ;
2022-11-16 17:31:26 +00:00
DROP INDEX eth . storage_leaf_key_block_number_index ;
2021-08-29 18:55:44 +00:00
-- state node indexes
2023-01-23 23:12:50 +00:00
DROP INDEX eth . state_code_hash_index ;
DROP INDEX eth . state_removed_index ;
2022-03-28 23:22:57 +00:00
DROP INDEX eth . state_header_id_index ;
2023-02-09 00:22:40 +00:00
DROP INDEX eth . state_cid_block_number_index ;
2022-03-15 21:06:13 +00:00
DROP INDEX eth . state_block_number_index ;
2022-11-16 17:31:26 +00:00
DROP INDEX eth . state_leaf_key_block_number_index ;
2021-08-29 18:55:44 +00:00
-- receipt indexes
DROP INDEX eth . rct_contract_index ;
2023-02-09 00:22:40 +00:00
DROP INDEX eth . rct_cid_block_number_index ;
2022-07-07 10:51:06 +00:00
DROP INDEX eth . rct_header_id_index ;
2022-03-15 21:06:13 +00:00
DROP INDEX eth . rct_block_number_index ;
2021-08-29 18:55:44 +00:00
-- transaction indexes
DROP INDEX eth . tx_src_index ;
DROP INDEX eth . tx_dst_index ;
2023-02-09 00:22:40 +00:00
DROP INDEX eth . tx_cid_block_number_index ;
2021-08-29 18:55:44 +00:00
DROP INDEX eth . tx_header_id_index ;
2022-03-15 21:06:13 +00:00
DROP INDEX eth . tx_block_number_index ;
2021-08-29 18:55:44 +00:00
2021-11-15 00:06:02 +00:00
-- uncle indexes
2022-03-15 21:06:13 +00:00
DROP INDEX eth . uncle_block_number_index ;
2023-02-09 00:22:40 +00:00
DROP INDEX eth . uncle_cid_block_number_index ;
2022-03-28 23:22:57 +00:00
DROP INDEX eth . uncle_header_id_index ;
2021-11-15 00:06:02 +00:00
2021-08-29 18:55:44 +00:00
-- header indexes
DROP INDEX eth . timestamp_index ;
DROP INDEX eth . state_root_index ;
2023-02-09 00:22:40 +00:00
DROP INDEX eth . header_cid_block_number_index ;
2022-03-15 21:06:13 +00:00
DROP INDEX eth . header_block_number_index ;