From e782de21b0f7f14276eb49bcc8a833394337461e Mon Sep 17 00:00:00 2001 From: Kyle Lawlor-Bagcal Date: Tue, 15 Aug 2023 11:00:46 -0400 Subject: [PATCH] feat: index tx.data tx_response code and type --- sql/V1_10__all_ecocredit_txes.sql | 10 ++++++++++ sql/V1_9__index_tx_response_code_and_type.sql | 1 + 2 files changed, 11 insertions(+) create mode 100644 sql/V1_10__all_ecocredit_txes.sql create mode 100644 sql/V1_9__index_tx_response_code_and_type.sql diff --git a/sql/V1_10__all_ecocredit_txes.sql b/sql/V1_10__all_ecocredit_txes.sql new file mode 100644 index 0000000..8f53e54 --- /dev/null +++ b/sql/V1_10__all_ecocredit_txes.sql @@ -0,0 +1,10 @@ +DROP FUNCTION IF EXISTS all_ecocredit_txes; + +CREATE FUNCTION all_ecocredit_txes () RETURNS SETOF tx AS $$ + select tx.* + from tx + natural join msg_event_attr as mea + where + data ->'tx_response'->'code' @> '0' + and mea.type like 'regen.ecocredit%' +$$ LANGUAGE SQL STABLE; diff --git a/sql/V1_9__index_tx_response_code_and_type.sql b/sql/V1_9__index_tx_response_code_and_type.sql new file mode 100644 index 0000000..33144c7 --- /dev/null +++ b/sql/V1_9__index_tx_response_code_and_type.sql @@ -0,0 +1 @@ +CREATE INDEX IF NOT EXISTS tx_data_tx_response_code_idx ON tx USING GIN ((DATA -> 'tx_response' -> 'code'));