aboutsummaryrefslogtreecommitdiff
path: root/src/exchangedb/exchange-0001-part.sql
diff options
context:
space:
mode:
authorMarco Boss <bossm8@bfh.ch>2022-04-06 13:33:47 +0200
committerMarco Boss <bossm8@bfh.ch>2022-04-06 13:33:47 +0200
commit0a10644b81212cd69e0047dd3a1c370340f1973c (patch)
tree97b372d0adda5ba2fc163dfe2eb1c396ceba1108 /src/exchangedb/exchange-0001-part.sql
parentadb999ce2cec29f20f240707bc7278f798d5b94b (diff)
improve some queries for sharding
Diffstat (limited to 'src/exchangedb/exchange-0001-part.sql')
-rw-r--r--src/exchangedb/exchange-0001-part.sql36
1 files changed, 26 insertions, 10 deletions
diff --git a/src/exchangedb/exchange-0001-part.sql b/src/exchangedb/exchange-0001-part.sql
index 2c416f03e..ce918a522 100644
--- a/src/exchangedb/exchange-0001-part.sql
+++ b/src/exchangedb/exchange-0001-part.sql
@@ -1466,17 +1466,33 @@ END IF;
-- Obtain KYC status based on the last wire transfer into
-- this reserve. FIXME: likely not adequate for reserves that got P2P transfers!
-SELECT
- kyc_ok
- ,wire_target_serial_id
- INTO
- kycok
+-- SELECT
+-- kyc_ok
+-- ,wire_target_serial_id
+-- INTO
+-- kycok
+-- ,account_uuid
+-- FROM reserves_in
+-- JOIN wire_targets ON (wire_source_h_payto = wire_target_h_payto)
+-- WHERE reserve_pub=rpub
+-- LIMIT 1; -- limit 1 should not be required (without p2p transfers)
+
+WITH reserves_in AS materialized (
+ SELECT wire_source_h_payto
+ FROM reserves_in WHERE
+ reserve_pub=rpub
+)
+SELECT
+ kyc_ok
+ ,wire_target_serial_id
+INTO
+ kycok
,account_uuid
- FROM reserves_in
- JOIN wire_targets ON (wire_source_h_payto = wire_target_h_payto)
- WHERE reserve_pub=rpub
- LIMIT 1; -- limit 1 should not be required (without p2p transfers)
-
+FROM wire_targets
+ WHERE wire_target_h_payto = (
+ SELECT wire_source_h_payto
+ FROM reserves_in
+ );
END $$;