-
Notifications
You must be signed in to change notification settings - Fork 513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize history tables for query by id performance(claimable balance, accounts, liquidity pools and assets) #4455
Comments
this issue was identified by @jcx120 and triaged in slack thread, @sydneynotthecity investigated the underlying sql query for the endpoint and mentioned in separate thread that |
Another item I would propose: changing the |
Update: optimizing the query does not provide measurable benefit to query runtimes; I recommend we leave the query unchanged. If we update the @sreuland do you know if we can add another index to this table? The table only has the following indices:
Since there is no index with |
@sydneynotthecity , I'll try new recommended index on staging db, it has a full copy of the pubnet data set on it's postgres instance, should be able get decent estimate of the net effect to this query, thanks! |
I think we should expand the scope of this ticket to cover operations by cb also, as those are triggering slow timeouts, alerts also. |
@sreuland the
I bet if we add a third index with We're have to ensure this additional index wouldn't impact routes that search on operation/transaction only if that's a common access pattern for this API. |
@sydneynotthecity @jcx120 , i tested on staging db the suggestion of new indexes from Syd, the staging db has full pubnet dataset, so it's comparable for measurement, the fix works great for ops and txs, the response time is now sub-second, can contrast the two here: staging with indexing thanks Syd! |
@sreuland do you know if any other Horizon route uses those two tables? Want to confirm that we're not impacting other existing traffic by adding the new indices to the tables. My assumption is this is the only route but want to be certain. |
Also in addition, would be curious to see if adding these indices significantly impacts DB storage footprint. |
@sydneynotthecity , it looks like usage of @jcx120 , I pulled the size of these new indexes, each took about 5.7GB of space in the DB, so a combined total of 11GB, buty that is just based on todays ledger size, that would grow as more cb entries are created. |
@sreuland l, as @sydneynotthecity suggested at #4396 we should consider the same indices for other objects (accounts, liquidity pools and assets) |
What version are you using?
Horizon 2.18.1
What did you do?
https://horizon.stellar.org/claimable_balances/0000000028b32c721976af53fa0419eba129f3da70168f1e39822a25886375abad9599da/transactions?limit=1&order=asc
What did you expect to see?
list of transactions related to entity returned in reasonably fast response time
list of tx's by entity covers a few types that can be vulnerable to this query path behavior, 'claimable balance', 'accounts', 'liquidity pool', 'assets', want to include optimization for each of these as they likely have same root cause in query performance.
What did you see instead?
503, timeout responses.
The text was updated successfully, but these errors were encountered: