Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding evm_chain_id, address and event_sig to data and topic indexes #12786

Merged
merged 9 commits into from
Apr 16, 2024
5 changes: 5 additions & 0 deletions .changeset/rich-jars-flow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

Narrowing topic, data_word indexes by adding (evm_chain_id, address, event_sig) to the index definition #db_update
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
-- +goose Up

drop index if exists evm.evm_logs_idx_data_word_one;
drop index if exists evm.evm_logs_idx_data_word_two;
drop index if exists evm.evm_logs_idx_data_word_three;
drop index if exists evm.evm_logs_idx_data_word_four;
drop index if exists evm.evm_logs_idx_topic_two;
drop index if exists evm.evm_logs_idx_topic_three;
drop index if exists evm.evm_logs_idx_topic_four;

create index evm_logs_idx_data_word_three
on evm.logs (evm_chain_id, address, event_sig, "substring"(data, 65, 32));
mateusz-sekara marked this conversation as resolved.
Show resolved Hide resolved

create index evm_logs_idx_data_word_five
on evm.logs (evm_chain_id, address, event_sig, "substring"(data, 129, 32));

create index evm_logs_idx_topic_two
on evm.logs (evm_chain_id, address, event_sig, (topics[2]));

create index evm_logs_idx_topic_three
on evm.logs (evm_chain_id, address, event_sig, (topics[3]));

create index evm_logs_idx_topic_four
on evm.logs (evm_chain_id, address, event_sig, (topics[4]));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happened to data words one, two, and four.?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed them because data word queries are used only by CCIP and we rely only on 3 and 5

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you feel it's too risky we can consider bringing them back. I just wanted to reduce number of redundant indexes from that table


-- +goose Down

drop index if exists evm.evm_logs_idx_data_word_three;
drop index if exists evm.evm_logs_idx_data_word_five;
drop index if exists evm.evm_logs_idx_topic_two;
drop index if exists evm.evm_logs_idx_topic_three;
drop index if exists evm.evm_logs_idx_topic_four;

create index evm_logs_idx_data_word_one
mateusz-sekara marked this conversation as resolved.
Show resolved Hide resolved
on evm.logs ("substring"(data, 1, 32));

create index evm_logs_idx_data_word_two
on evm.logs ("substring"(data, 33, 32));

create index evm_logs_idx_data_word_three
on evm.logs ("substring"(data, 65, 32));

create index evm_logs_idx_data_word_four
on evm.logs ("substring"(data, 97, 32));

create index evm_logs_idx_topic_two
on evm.logs ((topics[2]));

create index evm_logs_idx_topic_three
on evm.logs ((topics[3]));

create index evm_logs_idx_topic_four
on evm.logs ((topics[4]));
Loading