aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb/plugin_exchangedb_postgres.c
diff options
context:
space:
mode:
authorChristian Grothoff <grothoff@gnunet.org>2022-03-19 14:05:45 +0100
committerChristian Grothoff <grothoff@gnunet.org>2022-03-19 14:05:45 +0100
commitf5e5f4b843f09f9b68ea1998ce18b369ccbcccd7 (patch)
tree88494d966f0b2d435640cfddc4fa2b5442fb9dd3 /src/exchangedb/plugin_exchangedb_postgres.c
parentf22125ce0fa074f0dbf090ccbbee3f119c94e619 (diff)
more work on recoup_by_reserve: add new materialized index to avoid hitting all partitions for the query
Diffstat (limited to 'src/exchangedb/plugin_exchangedb_postgres.c')
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index c078d65a..1b370ff3 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -1646,12 +1646,12 @@ prepare_statements (struct PostgresClosure *pg)
GNUNET_PQ_make_prepare (
"recoup_by_reserve",
"SELECT "
- " coins.coin_pub,"
- " coin_sig,"
- " coin_blind,"
- " amount_val,"
- " amount_frac,"
- " recoup_timestamp,"
+ " rc.coin_pub,"
+ " rc.coin_sig,"
+ " rc.coin_blind,"
+ " rc.amount_val,"
+ " rc.amount_frac,"
+ " rc.recoup_timestamp,"
" denoms.denom_pub_hash,"
" coins.denom_sig"
" FROM reserves res"
@@ -1659,8 +1659,10 @@ prepare_statements (struct PostgresClosure *pg)
" ON (res.reserve_uuid = ror.reserve_uuid)"
" JOIN reserves_out ro"
" ON (ror.h_blind_ev = ro.h_blind_ev)"
+ " JOIN recoup_by_reserve rbr"
+ " ON (rbr.reserve_out_serial_id = ro.reserve_out_serial_id)"
" JOIN recoup rc"
- " ON (ro.reserve_out_serial_id = rc.reserve_out_serial_id)"
+ " ON (rbr.coin_pub = rc.coin_pub)"
" JOIN known_coins coins"
" ON (rc.coin_pub = coins.coin_pub)"
" JOIN denominations denoms"