rewrite query for recoup_by_reserve

This commit is contained in:
Marco Boss 2022-03-04 13:22:28 +01:00
parent f9a2808ed0
commit f5e1cf5e6d
No known key found for this signature in database
GPG Key ID: 89A3EC33C625C3DF

View File

@ -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