aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb
diff options
context:
space:
mode:
authorMarco Boss <bossm8@bfh.ch>2022-03-04 13:22:28 +0100
committerMarco Boss <bossm8@bfh.ch>2022-03-04 13:22:28 +0100
commitf5e1cf5e6d597a0d0026941691de3ed1bdc5dbb0 (patch)
tree5985f2944c241230569e2ae9b858194073e7ad70 /src/exchangedb
parentf9a2808ed02535427e4d2a8a45bcdc9777b8caf5 (diff)
rewrite query for recoup_by_reserve
Diffstat (limited to 'src/exchangedb')
-rw-r--r--src/exchangedb/plugin_exchangedb_postgres.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/exchangedb/plugin_exchangedb_postgres.c b/src/exchangedb/plugin_exchangedb_postgres.c
index bdb15c4e5..754654e32 100644
--- a/src/exchangedb/plugin_exchangedb_postgres.c
+++ b/src/exchangedb/plugin_exchangedb_postgres.c
@@ -1579,27 +1579,29 @@ prepare_statements (struct PostgresClosure *pg)
" ORDER BY close_uuid ASC;",
1),
/* Used in #postgres_get_reserve_history() to obtain recoup transactions
- for a reserve */
+ for a reserve - query optimization should be disabled i.e.
+ BEGIN; SET LOCAL join_collapse_limit=1; query; COMMIT; */
GNUNET_PQ_make_prepare (
"recoup_by_reserve",
- "SELECT"
- " coins.coin_pub"
- ",coin_sig"
- ",coin_blind"
- ",amount_val"
- ",amount_frac"
- ",recoup_timestamp"
- ",denoms.denom_pub_hash"
- ",coins.denom_sig"
- " FROM reserves"
- " JOIN reserves_out ro"
- " USING (reserve_uuid)"
- " JOIN recoup"
- " USING (reserve_out_serial_id)"
+ "SELECT "
+ " coins.coin_pub,"
+ " coin_sig,"
+ " coin_blind,"
+ " amount_val,"
+ " amount_frac,"
+ " recoup_timestamp,"
+ " denoms.denom_pub_hash,"
+ " coins.denom_sig"
+ " FROM denominations denoms"
" JOIN known_coins coins"
- " USING (known_coin_id)"
- " JOIN denominations denoms"
- " ON (coins.denominations_serial = denoms.denominations_serial)"
+ " ON (coins.denominations_serial = denoms.denominations_serial)"
+ " JOIN recoup"
+ " USING (known_coin_id)"
+ " JOIN ("
+ " reserves_out"
+ " JOIN reserves"
+ " USING (reserve_uuid)"
+ " ) USING (reserve_out_serial_id)"
" WHERE reserve_pub=$1;",
1),
/* Used in #postgres_get_coin_transactions() to obtain recoup transactions