diff options
author | Christian Grothoff <grothoff@gnunet.org> | 2023-10-17 10:37:55 +0200 |
---|---|---|
committer | Christian Grothoff <grothoff@gnunet.org> | 2023-10-17 10:37:55 +0200 |
commit | c190a1cdfce1cdecfcc25fd851f53e853377d5a9 (patch) | |
tree | de6693b4e1fbe03deff27b0662b7e59b47b74662 | |
parent | 4e380d4937da4d51809d57eb60d4b6f0650483a9 (diff) |
-use partial indices where applicable
-rw-r--r-- | src/exchangedb/0002-prewire.sql | 16 | ||||
-rw-r--r-- | src/exchangedb/exchange_do_reserve_open.sql | 2 | ||||
-rw-r--r-- | src/exchangedb/pg_wire_prepare_data_get.c | 2 | ||||
-rw-r--r-- | src/exchangedb/pg_wire_prepare_data_mark_failed.c | 2 | ||||
-rw-r--r-- | src/exchangedb/pg_wire_prepare_data_mark_finished.c | 2 |
5 files changed, 10 insertions, 14 deletions
diff --git a/src/exchangedb/0002-prewire.sql b/src/exchangedb/0002-prewire.sql index 8dc8cd5d6..396a27608 100644 --- a/src/exchangedb/0002-prewire.sql +++ b/src/exchangedb/0002-prewire.sql @@ -1,6 +1,6 @@ -- -- This file is part of TALER --- Copyright (C) 2014--2022 Taler Systems SA +-- Copyright (C) 2014--2023 Taler Systems SA -- -- TALER is free software; you can redistribute it and/or modify it under the -- terms of the GNU General Public License as published by the Free Software @@ -27,8 +27,8 @@ BEGIN 'CREATE TABLE %I' '(prewire_uuid BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY' ',wire_method TEXT NOT NULL' - ',finished BOOLEAN NOT NULL DEFAULT false' - ',failed BOOLEAN NOT NULL DEFAULT false' + ',finished BOOLEAN NOT NULL DEFAULT FALSE' + ',failed BOOLEAN NOT NULL DEFAULT FALSE' ',buf BYTEA NOT NULL' ') %s ;' ,table_name @@ -75,17 +75,19 @@ BEGIN EXECUTE FORMAT ( 'CREATE INDEX ' || table_name || '_by_finished_index ' 'ON ' || table_name || ' ' - '(finished);' + '(finished)' + ' WHERE finished;' ); EXECUTE FORMAT ( 'COMMENT ON INDEX ' || table_name || '_by_finished_index ' - 'IS ' || quote_literal('for gc_prewire') || ';' + 'IS ' || quote_literal('for do_gc') || ';' ); - -- FIXME: find a way to combine these two indices? EXECUTE FORMAT ( 'CREATE INDEX ' || table_name || '_by_failed_finished_index ' 'ON ' || table_name || ' ' - '(failed,finished);' + '(prewire_uuid)' + ' WHERE finished=FALSE' + ' AND failed=FALSE;' ); EXECUTE FORMAT ( 'COMMENT ON INDEX ' || table_name || '_by_failed_finished_index ' diff --git a/src/exchangedb/exchange_do_reserve_open.sql b/src/exchangedb/exchange_do_reserve_open.sql index f37129e55..dd7a578ee 100644 --- a/src/exchangedb/exchange_do_reserve_open.sql +++ b/src/exchangedb/exchange_do_reserve_open.sql @@ -44,7 +44,7 @@ DECLARE BEGIN SELECT current_balance - ,expiration_time + ,expiration_date ,purses_allowed INTO reserve FROM reserves diff --git a/src/exchangedb/pg_wire_prepare_data_get.c b/src/exchangedb/pg_wire_prepare_data_get.c index 21d1b947a..0cc57e41f 100644 --- a/src/exchangedb/pg_wire_prepare_data_get.c +++ b/src/exchangedb/pg_wire_prepare_data_get.c @@ -117,8 +117,6 @@ TEH_PG_wire_prepare_data_get (void *cls, }; enum GNUNET_DB_QueryStatus qs; - - /* Used in #postgres_wire_prepare_data_get() */ PREPARE (pg, "wire_prepare_data_get", "SELECT" diff --git a/src/exchangedb/pg_wire_prepare_data_mark_failed.c b/src/exchangedb/pg_wire_prepare_data_mark_failed.c index 4e4d729a3..1d46c84d4 100644 --- a/src/exchangedb/pg_wire_prepare_data_mark_failed.c +++ b/src/exchangedb/pg_wire_prepare_data_mark_failed.c @@ -37,8 +37,6 @@ TEH_PG_wire_prepare_data_mark_failed ( GNUNET_PQ_query_param_end }; - /* Used in #postgres_wire_prepare_data_mark_failed() */ - PREPARE (pg, "wire_prepare_data_mark_failed", "UPDATE prewire" diff --git a/src/exchangedb/pg_wire_prepare_data_mark_finished.c b/src/exchangedb/pg_wire_prepare_data_mark_finished.c index af4a0fbbb..998b9d731 100644 --- a/src/exchangedb/pg_wire_prepare_data_mark_finished.c +++ b/src/exchangedb/pg_wire_prepare_data_mark_finished.c @@ -36,13 +36,11 @@ TEH_PG_wire_prepare_data_mark_finished ( GNUNET_PQ_query_param_end }; - /* Used in #postgres_wire_prepare_data_mark_finished() */ PREPARE (pg, "wire_prepare_data_mark_done", "UPDATE prewire" " SET finished=TRUE" " WHERE prewire_uuid=$1;"); - return GNUNET_PQ_eval_prepared_non_select (pg->conn, "wire_prepare_data_mark_done", params); |