Skip to content

Conversation

agodnic
Copy link

@agodnic agodnic commented Feb 27, 2025

Summary

Sync with the latest upstream commit. In particular, add support for the online-only parameter in GET /v2/accounts to search for online accounts.

Note that the parameter is disabled by default.

Performance

The performance of is-online=true lookups can be improved with the following index:

-- create the index
defaultdb> CREATE INDEX account_idx_online_only                                                                                                                                         
->         ON account ((((account_data ->> 'onl')) = '1'), addr)                                                                                                                
->         WHERE (NOT deleted) AND ((account_data ->> 'onl') IS NOT NULL) AND ((account_data ->> 'voteLst') IS NOT NULL)                                                        
-> ;                                                                                                                                                                            
CREATE INDEX

Time: 535ms total (execution 257ms / network 278ms)

-- make sure the index is being used
defaultdb> explain  WITH qaccounts AS (SELECT a.addr, a.microalgos, a.rewards_total, a.created_at, a.closed_at, a.deleted, a.rewardsbase, a.keytype, a.account_data FROM account a      
                                 -> WHERE NOT a.deleted AND (a.account_data->>'onl' IS NOT NULL) and (account_data->>'voteLst' IS NOT NULL) and ((a.account_data->>'onl') = '1') ORDER BY a.addr ASC LIMIT 10)   
                                 -> SELECT za.addr, za.microalgos, za.rewards_total, za.created_at, za.closed_at, za.deleted, za.rewardsbase, za.keytype, za.account_data FROM qaccounts za ORDER BY za.addr     
                                 -> ASC;                                                                                                                                                                         
                                         info
---------------------------------------------------------------------------------------
  distribution: local
  vectorized: true

  • render
  │
  └── • index join
      │ estimated row count: 10
      │ table: account@account_pkey
      │
      └── • scan
            estimated row count: 10 (0.04% of the table; stats collected 2 hours ago)
            table: account@account_idx_online_only (partial index)
            spans: [/true - /true]
            limit: 10
(14 rows)

Time: 280ms total (execution 2ms / network 278ms)

@agodnic agodnic marked this pull request as ready for review February 27, 2025 20:39
@agodnic agodnic requested a review from urtho February 27, 2025 20:39
@agodnic agodnic merged commit 97b0ad2 into main Jul 31, 2025
4 checks passed
@agodnic agodnic deleted the sync-with-upstream branch July 31, 2025 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant