From 7105a94dc9cf7412260b6d99e276a7ef9573488a Mon Sep 17 00:00:00 2001 From: Warren He Date: Fri, 23 Jun 2023 17:05:20 -0700 Subject: [PATCH] storage: add chain.evm_tokens token_name index --- storage/migrations/08_evm_tokens_name_index.up.sql | 10 ++++++++++ storage/postgres/client.go | 2 ++ 2 files changed, 12 insertions(+) create mode 100644 storage/migrations/08_evm_tokens_name_index.up.sql diff --git a/storage/migrations/08_evm_tokens_name_index.up.sql b/storage/migrations/08_evm_tokens_name_index.up.sql new file mode 100644 index 000000000..2c6ab4eb0 --- /dev/null +++ b/storage/migrations/08_evm_tokens_name_index.up.sql @@ -0,0 +1,10 @@ +-- Add a indexes for evm_tokens token names and symbols for search. + +BEGIN; + +CREATE EXTENSION pg_trgm; + +CREATE INDEX ix_evm_tokens_name ON chain.evm_tokens USING GIST (token_name gist_trgm_ops); +CREATE INDEX ix_evm_tokens_symbol ON chain.evm_tokens USING GIST (symbol gist_trgm_ops); + +COMMIT; diff --git a/storage/postgres/client.go b/storage/postgres/client.go index 366836e54..a03714027 100644 --- a/storage/postgres/client.go +++ b/storage/postgres/client.go @@ -322,6 +322,7 @@ func (c *Client) Wipe(ctx context.Context) error { // List, then drop all custom types. // Query from https://stackoverflow.com/questions/3660787/how-to-list-custom-types-using-postgres-information-schema + // TODO: Don't delete extensions' types. types, err := c.listIndexerTypes(ctx) for _, typ := range types { c.logger.Info("dropping type", "type", typ) @@ -331,6 +332,7 @@ func (c *Client) Wipe(ctx context.Context) error { } // List, then drop all custom functions. + // TODO: Don't delete extensions' functions. functions, err := c.listIndexerFunctions(ctx) if err != nil { return err