• Resolved hjroh7

    (@hjroh7)


    Hi suppor team,

    I am really enjoying your product. It is simple and robust.

    Anyway, I happened to look at the get_wallet_balance function code, and the code was analyzed as performing the entire sum every time through the db query executed by the get_wallet_transactions function retrieving changes that occurred from the beginning to the present whenever the credit/debit transactions happen. Of course, the mechanism of storing the result value with the query as a hash key in the cache is applied and the value is fetched directly from the cache instead of doing a db query until the balance changes. However, I am concerned about the overhead, in particular, if the usage is frequent and the usage time is getting longer, there will be more data and I am worried that the problem in calculating the balance will become serious.
    By the way, I saw the code that calculated the user’s latest balance as $meta_key = ‘_current_woo_wallet_balance’ in the wp_usermeta table. When executing the get_wallet_balance function, it seems that it is enough to simply select a single balance data from the corresponding meta record. Is there any special reason for calculating the balance by querying all transactions and summing them?

The topic ‘Regarding Woo_Wallet_Wallet class get_wallet_balance function efficiency’ is closed to new replies.