From 95f52a1f22190c9f22a9810007d6ae2dce84be73 Mon Sep 17 00:00:00 2001 From: Jeffery Walsh Date: Mon, 12 Jun 2023 00:45:29 -0700 Subject: [PATCH] relayer is slow due to inefficient indexing in sql --- ...add_message_owner_event_type_chain_id_event_index.sql | 9 +++++++++ ...table_add_message_owner_event_type_chain_id_index.sql | 9 +++++++++ ...r_events_table_add_message_owner_event_type_index.sql | 9 +++++++++ ...650704_alter_events_table_add_message_owner_index.sql | 9 +++++++++ .../1666650705_alter_events_table_add_msg_hash_index.sql | 9 +++++++++ ...ter_events_table_add_message_owner_chain_id_index.sql | 9 +++++++++ ..._alter_events_table_add_message_owner_event_index.sql | 9 +++++++++ 7 files changed, 63 insertions(+) create mode 100644 packages/relayer/migrations/1666650701_alter_events_table_add_message_owner_event_type_chain_id_event_index.sql create mode 100644 packages/relayer/migrations/1666650702_alter_events_table_add_message_owner_event_type_chain_id_index.sql create mode 100644 packages/relayer/migrations/1666650703_alter_events_table_add_message_owner_event_type_index.sql create mode 100644 packages/relayer/migrations/1666650704_alter_events_table_add_message_owner_index.sql create mode 100644 packages/relayer/migrations/1666650705_alter_events_table_add_msg_hash_index.sql create mode 100644 packages/relayer/migrations/1666650706_alter_events_table_add_message_owner_chain_id_index.sql create mode 100644 packages/relayer/migrations/1666650707_alter_events_table_add_message_owner_event_index.sql diff --git a/packages/relayer/migrations/1666650701_alter_events_table_add_message_owner_event_type_chain_id_event_index.sql b/packages/relayer/migrations/1666650701_alter_events_table_add_message_owner_event_type_chain_id_event_index.sql new file mode 100644 index 00000000000..6f74f4631d8 --- /dev/null +++ b/packages/relayer/migrations/1666650701_alter_events_table_add_message_owner_event_type_chain_id_event_index.sql @@ -0,0 +1,9 @@ +-- +goose Up +-- +goose StatementBegin +ALTER TABLE `events` ADD INDEX `message_owner_event_type_chain_id_event_index` (`message_owner`, `event_type`, `chain_id`, `event`); + +-- +goose StatementEnd +-- +goose Down +-- +goose StatementBegin +DROP INDEX message_owner_event_type_chain_id_event_index on events; +-- +goose StatementEnd \ No newline at end of file diff --git a/packages/relayer/migrations/1666650702_alter_events_table_add_message_owner_event_type_chain_id_index.sql b/packages/relayer/migrations/1666650702_alter_events_table_add_message_owner_event_type_chain_id_index.sql new file mode 100644 index 00000000000..0d774786213 --- /dev/null +++ b/packages/relayer/migrations/1666650702_alter_events_table_add_message_owner_event_type_chain_id_index.sql @@ -0,0 +1,9 @@ +-- +goose Up +-- +goose StatementBegin +ALTER TABLE `events` ADD INDEX `message_owner_event_type_chain_id_index` (`message_owner`, `event_type`, `chain_id`); + +-- +goose StatementEnd +-- +goose Down +-- +goose StatementBegin +DROP INDEX message_owner_event_type_chain_id_index on events; +-- +goose StatementEnd \ No newline at end of file diff --git a/packages/relayer/migrations/1666650703_alter_events_table_add_message_owner_event_type_index.sql b/packages/relayer/migrations/1666650703_alter_events_table_add_message_owner_event_type_index.sql new file mode 100644 index 00000000000..e9709e87f7e --- /dev/null +++ b/packages/relayer/migrations/1666650703_alter_events_table_add_message_owner_event_type_index.sql @@ -0,0 +1,9 @@ +-- +goose Up +-- +goose StatementBegin +ALTER TABLE `events` ADD INDEX `message_owner_event_type_index` (`message_owner`, `event_type`); + +-- +goose StatementEnd +-- +goose Down +-- +goose StatementBegin +DROP INDEX message_owner_event_type_index on events; +-- +goose StatementEnd \ No newline at end of file diff --git a/packages/relayer/migrations/1666650704_alter_events_table_add_message_owner_index.sql b/packages/relayer/migrations/1666650704_alter_events_table_add_message_owner_index.sql new file mode 100644 index 00000000000..f988d47f30f --- /dev/null +++ b/packages/relayer/migrations/1666650704_alter_events_table_add_message_owner_index.sql @@ -0,0 +1,9 @@ +-- +goose Up +-- +goose StatementBegin +ALTER TABLE `events` ADD INDEX `message_owner_index` (`message_owner`); + +-- +goose StatementEnd +-- +goose Down +-- +goose StatementBegin +DROP INDEX message_owner_index on events; +-- +goose StatementEnd \ No newline at end of file diff --git a/packages/relayer/migrations/1666650705_alter_events_table_add_msg_hash_index.sql b/packages/relayer/migrations/1666650705_alter_events_table_add_msg_hash_index.sql new file mode 100644 index 00000000000..df4c1c17f29 --- /dev/null +++ b/packages/relayer/migrations/1666650705_alter_events_table_add_msg_hash_index.sql @@ -0,0 +1,9 @@ +-- +goose Up +-- +goose StatementBegin +ALTER TABLE `events` ADD INDEX `msg_hash_index` (`msg_hash`); + +-- +goose StatementEnd +-- +goose Down +-- +goose StatementBegin +DROP INDEX msg_hash_index on events; +-- +goose StatementEnd \ No newline at end of file diff --git a/packages/relayer/migrations/1666650706_alter_events_table_add_message_owner_chain_id_index.sql b/packages/relayer/migrations/1666650706_alter_events_table_add_message_owner_chain_id_index.sql new file mode 100644 index 00000000000..c6432297811 --- /dev/null +++ b/packages/relayer/migrations/1666650706_alter_events_table_add_message_owner_chain_id_index.sql @@ -0,0 +1,9 @@ +-- +goose Up +-- +goose StatementBegin +ALTER TABLE `events` ADD INDEX `message_owner_chain_id_index` (`message_owner`,`chain_id`); + +-- +goose StatementEnd +-- +goose Down +-- +goose StatementBegin +DROP INDEX message_owner_chain_id_index on events; +-- +goose StatementEnd \ No newline at end of file diff --git a/packages/relayer/migrations/1666650707_alter_events_table_add_message_owner_event_index.sql b/packages/relayer/migrations/1666650707_alter_events_table_add_message_owner_event_index.sql new file mode 100644 index 00000000000..2fdd76688c8 --- /dev/null +++ b/packages/relayer/migrations/1666650707_alter_events_table_add_message_owner_event_index.sql @@ -0,0 +1,9 @@ +-- +goose Up +-- +goose StatementBegin +ALTER TABLE `events` ADD INDEX `message_owner_event_index` (`message_owner`,`event`); + +-- +goose StatementEnd +-- +goose Down +-- +goose StatementBegin +DROP INDEX message_owner_event_index on events; +-- +goose StatementEnd \ No newline at end of file