diff options
author | Christian Grothoff <grothoff@gnunet.org> | 2023-10-17 11:10:34 +0200 |
---|---|---|
committer | Christian Grothoff <grothoff@gnunet.org> | 2023-10-17 11:10:34 +0200 |
commit | f2a28c54cc05082acc02784e5e5e401ee6848413 (patch) | |
tree | ee1383b1ef9e4e5d811737f4f254d635693f6f00 /src | |
parent | c741c1fa718e144548b5508e85e469ec93f73b54 (diff) | |
download | exchange-f2a28c54cc05082acc02784e5e5e401ee6848413.tar.xz |
kill another dead index, beautify SQL
Diffstat (limited to 'src')
-rw-r--r-- | src/exchangedb/0002-account_merges.sql | 7 | ||||
-rw-r--r-- | src/exchangedb/0002-purse_merges.sql | 11 | ||||
-rw-r--r-- | src/exchangedb/exchange_do_purse_deposit.sql | 4 | ||||
-rw-r--r-- | src/exchangedb/exchange_do_purse_merge.sql | 8 | ||||
-rw-r--r-- | src/exchangedb/exchange_do_reserve_purse.sql | 6 |
5 files changed, 17 insertions, 19 deletions
diff --git a/src/exchangedb/0002-account_merges.sql b/src/exchangedb/0002-account_merges.sql index e791b60d0..1dd7e5bf0 100644 --- a/src/exchangedb/0002-account_merges.sql +++ b/src/exchangedb/0002-account_merges.sql @@ -74,6 +74,13 @@ DECLARE BEGIN table_name = concat_ws('_', table_name, partition_suffix); + -- Note: this index *may* be useful in + -- pg_get_reserve_history depending on how + -- smart the DB is when computing the JOIN. + -- Removing it MAY boost performance slightly, at + -- the expense of trouble if the "merge_by_reserve" + -- query planner goes off the rails. Needs benchmarking + -- to be sure. EXECUTE FORMAT ( 'CREATE INDEX ' || table_name || '_by_reserve_pub ' 'ON ' || table_name || ' ' diff --git a/src/exchangedb/0002-purse_merges.sql b/src/exchangedb/0002-purse_merges.sql index 178a36ccf..0b4d230b3 100644 --- a/src/exchangedb/0002-purse_merges.sql +++ b/src/exchangedb/0002-purse_merges.sql @@ -86,16 +86,7 @@ DECLARE table_name TEXT DEFAULT 'purse_merges'; BEGIN table_name = concat_ws('_', table_name, partition_suffix); - -- FIXME: change to materialized index by reserve_pub! - EXECUTE FORMAT ( - 'CREATE INDEX ' || table_name || '_reserve_pub ' - 'ON ' || table_name || ' ' - '(reserve_pub);' - ); - EXECUTE FORMAT ( - 'COMMENT ON INDEX ' || table_name || '_reserve_pub ' - 'IS ' || quote_literal('needed in reserve history computation') || ';' - ); + EXECUTE FORMAT ( 'ALTER TABLE ' || table_name || ' ADD CONSTRAINT ' || table_name || '_purse_merge_request_serial_id_key' diff --git a/src/exchangedb/exchange_do_purse_deposit.sql b/src/exchangedb/exchange_do_purse_deposit.sql index 1e97e2a17..49d3c919b 100644 --- a/src/exchangedb/exchange_do_purse_deposit.sql +++ b/src/exchangedb/exchange_do_purse_deposit.sql @@ -155,7 +155,7 @@ SELECT COALESCE(partner_serial_id,0) ,reserve_pub INTO psi ,my_reserve_pub - FROM exchange.purse_merges + FROM purse_merges WHERE purse_pub=in_purse_pub; IF NOT FOUND @@ -212,7 +212,7 @@ THEN SET purses_active=purses_active-1 WHERE reserve_pub IN (SELECT reserve_pub - FROM exchange.purse_merges + FROM purse_merges WHERE purse_pub=my_purse_pub LIMIT 1); END IF; diff --git a/src/exchangedb/exchange_do_purse_merge.sql b/src/exchangedb/exchange_do_purse_merge.sql index 7f8af9ed7..946fd7e97 100644 --- a/src/exchangedb/exchange_do_purse_merge.sql +++ b/src/exchangedb/exchange_do_purse_merge.sql @@ -104,7 +104,7 @@ my_in_reserve_quota := rval.in_reserve_quota; out_no_balance=FALSE; -- Store purse merge signature, checks for purse_pub uniqueness -INSERT INTO exchange.purse_merges +INSERT INTO purse_merges (partner_serial_id ,reserve_pub ,purse_pub @@ -124,7 +124,7 @@ THEN -- Note that by checking 'merge_sig', we implicitly check -- identity over everything that the signature covers. PERFORM - FROM exchange.purse_merges + FROM purse_merges WHERE purse_pub=in_purse_pub AND merge_sig=in_merge_sig; IF NOT FOUND @@ -169,13 +169,13 @@ THEN SET purses_active=purses_active-1 WHERE reserve_pub IN (SELECT reserve_pub - FROM exchange.purse_merges + FROM purse_merges WHERE purse_pub=my_purse_pub LIMIT 1); END IF; -- Store account merge signature. -INSERT INTO exchange.account_merges +INSERT INTO account_merges (reserve_pub ,reserve_sig ,purse_pub diff --git a/src/exchangedb/exchange_do_reserve_purse.sql b/src/exchangedb/exchange_do_reserve_purse.sql index 43d4c91a8..8ae652e69 100644 --- a/src/exchangedb/exchange_do_reserve_purse.sql +++ b/src/exchangedb/exchange_do_reserve_purse.sql @@ -33,7 +33,7 @@ AS $$ BEGIN -- Store purse merge signature, checks for purse_pub uniqueness -INSERT INTO exchange.purse_merges +INSERT INTO purse_merges (partner_serial_id ,reserve_pub ,purse_pub @@ -53,7 +53,7 @@ THEN -- Note that by checking 'merge_sig', we implicitly check -- identity over everything that the signature covers. PERFORM - FROM exchange.purse_merges + FROM purse_merges WHERE purse_pub=in_purse_pub AND merge_sig=in_merge_sig; IF NOT FOUND @@ -145,7 +145,7 @@ out_no_funds=FALSE; -- Store account merge signature. -INSERT INTO exchange.account_merges +INSERT INTO account_merges (reserve_pub ,reserve_sig ,purse_pub |