try to optimize aggregator queries
This commit is contained in:
parent
65533e8df5
commit
c8480d97a1
@ -378,7 +378,7 @@ COMMENT ON COLUMN extension_details.extension_options
|
|||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS deposits
|
CREATE TABLE IF NOT EXISTS deposits
|
||||||
(deposit_serial_id BIGSERIAL PRIMARY KEY
|
(deposit_serial_id BIGSERIAL PRIMARY KEY
|
||||||
,shard INT8 NOT NULL DEFAULT 0
|
,shard INT8 NOT NULL
|
||||||
,known_coin_id INT8 NOT NULL REFERENCES known_coins (known_coin_id) ON DELETE CASCADE
|
,known_coin_id INT8 NOT NULL REFERENCES known_coins (known_coin_id) ON DELETE CASCADE
|
||||||
,amount_with_fee_val INT8 NOT NULL
|
,amount_with_fee_val INT8 NOT NULL
|
||||||
,amount_with_fee_frac INT4 NOT NULL
|
,amount_with_fee_frac INT4 NOT NULL
|
||||||
@ -400,7 +400,7 @@ CREATE TABLE IF NOT EXISTS deposits
|
|||||||
COMMENT ON TABLE deposits
|
COMMENT ON TABLE deposits
|
||||||
IS 'Deposits we have received and for which we need to make (aggregate) wire transfers (and manage refunds).';
|
IS 'Deposits we have received and for which we need to make (aggregate) wire transfers (and manage refunds).';
|
||||||
COMMENT ON COLUMN deposits.shard
|
COMMENT ON COLUMN deposits.shard
|
||||||
IS 'Used for load sharding. Should be set based on h_payto and merchant_pub. Default of 0 onlyapplies for columns migrated from a previous version without sharding support. 64-bit value because we need an *unsigned* 32-bit value.';
|
IS 'Used for load sharding. Should be set based on h_payto and merchant_pub. 64-bit value because we need an *unsigned* 32-bit value.';
|
||||||
COMMENT ON COLUMN deposits.wire_target_serial_id
|
COMMENT ON COLUMN deposits.wire_target_serial_id
|
||||||
IS 'Identifies the target bank account and KYC status';COMMENT ON COLUMN deposits.wire_salt
|
IS 'Identifies the target bank account and KYC status';COMMENT ON COLUMN deposits.wire_salt
|
||||||
IS 'Salt used when hashing the payto://-URI to get the h_wire';
|
IS 'Salt used when hashing the payto://-URI to get the h_wire';
|
||||||
@ -423,12 +423,11 @@ COMMENT ON INDEX deposits_coin_pub_merchant_contract_index
|
|||||||
IS 'for get_deposit_for_wtid and test_deposit_done';
|
IS 'for get_deposit_for_wtid and test_deposit_done';
|
||||||
CREATE INDEX IF NOT EXISTS deposits_get_ready_index
|
CREATE INDEX IF NOT EXISTS deposits_get_ready_index
|
||||||
ON deposits
|
ON deposits
|
||||||
(shard
|
(shard ASC
|
||||||
,wire_deadline
|
|
||||||
,refund_deadline
|
|
||||||
,tiny
|
|
||||||
,done
|
,done
|
||||||
,extension_blocked
|
,extension_blocked
|
||||||
|
,tiny
|
||||||
|
,wire_deadline ASC
|
||||||
);
|
);
|
||||||
COMMENT ON INDEX deposits_coin_pub_merchant_contract_index
|
COMMENT ON INDEX deposits_coin_pub_merchant_contract_index
|
||||||
IS 'for deposits_get_ready';
|
IS 'for deposits_get_ready';
|
||||||
@ -438,7 +437,7 @@ CREATE INDEX IF NOT EXISTS deposits_iterate_matching_index
|
|||||||
,wire_target_serial_id
|
,wire_target_serial_id
|
||||||
,done
|
,done
|
||||||
,extension_blocked
|
,extension_blocked
|
||||||
,wire_deadline
|
,refund_deadline ASC
|
||||||
);
|
);
|
||||||
COMMENT ON INDEX deposits_iterate_matching_index
|
COMMENT ON INDEX deposits_iterate_matching_index
|
||||||
IS 'for deposits_iterate_matching';
|
IS 'for deposits_iterate_matching';
|
||||||
|
@ -1105,10 +1105,10 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
" WHERE "
|
" WHERE "
|
||||||
" shard >= $2"
|
" shard >= $2"
|
||||||
" AND shard <= $3"
|
" AND shard <= $3"
|
||||||
" AND wire_deadline<=$1"
|
|
||||||
" AND refund_deadline<$1"
|
|
||||||
" AND tiny=FALSE"
|
|
||||||
" AND done=FALSE"
|
" AND done=FALSE"
|
||||||
|
" AND extension_blocked=FALSE"
|
||||||
|
" AND tiny=FALSE"
|
||||||
|
" AND wire_deadline<=$1"
|
||||||
" AND (kyc_ok OR $4)"
|
" AND (kyc_ok OR $4)"
|
||||||
" ORDER BY "
|
" ORDER BY "
|
||||||
" shard ASC"
|
" shard ASC"
|
||||||
@ -1130,14 +1130,16 @@ prepare_statements (struct PostgresClosure *pg)
|
|||||||
" JOIN known_coins kc USING (known_coin_id)"
|
" JOIN known_coins kc USING (known_coin_id)"
|
||||||
" JOIN denominations denom USING (denominations_serial)"
|
" JOIN denominations denom USING (denominations_serial)"
|
||||||
" WHERE"
|
" WHERE"
|
||||||
" merchant_pub=$1 AND"
|
" merchant_pub=$1"
|
||||||
" wire_target_serial_id=$2 AND"
|
" AND wire_target_serial_id=$2"
|
||||||
" done=FALSE"
|
" AND done=FALSE"
|
||||||
" ORDER BY wire_deadline ASC"
|
" AND extension_blocked=FALSE"
|
||||||
|
" AND refund_deadline<$3"
|
||||||
|
" ORDER BY refund_deadline ASC"
|
||||||
" LIMIT "
|
" LIMIT "
|
||||||
TALER_QUOTE (
|
TALER_QUOTE (
|
||||||
TALER_EXCHANGEDB_MATCHING_DEPOSITS_LIMIT) ";",
|
TALER_EXCHANGEDB_MATCHING_DEPOSITS_LIMIT) ";",
|
||||||
2),
|
3),
|
||||||
/* Used in #postgres_mark_deposit_tiny() */
|
/* Used in #postgres_mark_deposit_tiny() */
|
||||||
GNUNET_PQ_make_prepare (
|
GNUNET_PQ_make_prepare (
|
||||||
"mark_deposit_tiny",
|
"mark_deposit_tiny",
|
||||||
@ -5505,9 +5507,11 @@ postgres_iterate_matching_deposits (
|
|||||||
uint32_t limit)
|
uint32_t limit)
|
||||||
{
|
{
|
||||||
struct PostgresClosure *pg = cls;
|
struct PostgresClosure *pg = cls;
|
||||||
|
struct GNUNET_TIME_Absolute now;
|
||||||
struct GNUNET_PQ_QueryParam params[] = {
|
struct GNUNET_PQ_QueryParam params[] = {
|
||||||
GNUNET_PQ_query_param_auto_from_type (merchant_pub),
|
GNUNET_PQ_query_param_auto_from_type (merchant_pub),
|
||||||
GNUNET_PQ_query_param_uint64 (&wire_target),
|
GNUNET_PQ_query_param_uint64 (&wire_target),
|
||||||
|
GNUNET_PQ_query_param_absolute_time (&now),
|
||||||
GNUNET_PQ_query_param_end
|
GNUNET_PQ_query_param_end
|
||||||
};
|
};
|
||||||
struct MatchingDepositContext mdc = {
|
struct MatchingDepositContext mdc = {
|
||||||
@ -5520,6 +5524,8 @@ postgres_iterate_matching_deposits (
|
|||||||
};
|
};
|
||||||
enum GNUNET_DB_QueryStatus qs;
|
enum GNUNET_DB_QueryStatus qs;
|
||||||
|
|
||||||
|
now = GNUNET_TIME_absolute_get ();
|
||||||
|
(void) GNUNET_TIME_round_abs (&now);
|
||||||
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
|
qs = GNUNET_PQ_eval_prepared_multi_select (pg->conn,
|
||||||
"deposits_iterate_matching",
|
"deposits_iterate_matching",
|
||||||
params,
|
params,
|
||||||
|
@ -83,7 +83,6 @@ struct TALER_EXCHANGE_DepositGetHandle
|
|||||||
* from the exchange is valid.
|
* from the exchange is valid.
|
||||||
*
|
*
|
||||||
* @param dwh deposit wtid handle
|
* @param dwh deposit wtid handle
|
||||||
* @param json json reply with the signature
|
|
||||||
* @param exchange_pub the exchange's public key
|
* @param exchange_pub the exchange's public key
|
||||||
* @param exchange_sig the exchange's signature
|
* @param exchange_sig the exchange's signature
|
||||||
* @return #GNUNET_OK if the signature is valid, #GNUNET_SYSERR if not
|
* @return #GNUNET_OK if the signature is valid, #GNUNET_SYSERR if not
|
||||||
@ -91,7 +90,6 @@ struct TALER_EXCHANGE_DepositGetHandle
|
|||||||
static enum GNUNET_GenericReturnValue
|
static enum GNUNET_GenericReturnValue
|
||||||
verify_deposit_wtid_signature_ok (
|
verify_deposit_wtid_signature_ok (
|
||||||
const struct TALER_EXCHANGE_DepositGetHandle *dwh,
|
const struct TALER_EXCHANGE_DepositGetHandle *dwh,
|
||||||
const json_t *json,
|
|
||||||
const struct TALER_ExchangePublicKeyP *exchange_pub,
|
const struct TALER_ExchangePublicKeyP *exchange_pub,
|
||||||
const struct TALER_ExchangeSignatureP *exchange_sig)
|
const struct TALER_ExchangeSignatureP *exchange_sig)
|
||||||
{
|
{
|
||||||
@ -177,7 +175,6 @@ handle_deposit_wtid_finished (void *cls,
|
|||||||
&dr.details.success.coin_contribution);
|
&dr.details.success.coin_contribution);
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
verify_deposit_wtid_signature_ok (dwh,
|
verify_deposit_wtid_signature_ok (dwh,
|
||||||
j,
|
|
||||||
&dr.details.success.exchange_pub,
|
&dr.details.success.exchange_pub,
|
||||||
&dr.details.success.exchange_sig))
|
&dr.details.success.exchange_sig))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user