-
Notifications
You must be signed in to change notification settings - Fork 11k
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
improve coin and balance query performance #17774
base: main
Are you sure you want to change the base?
Conversation
… and modify necessary coin indexes to support coin queries
The latest updates on your projects. Learn more about Vercel for Git ↗︎ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
// Since we have partial indexes on `coin_type IS NOT NULL` and `owner_type = 1`, every coin | ||
// query will have this filter condition. | ||
filter!(query, format!("owner_type = {}", OwnerType::Address as i16)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the correctness argument for this filter. Coins can be shared or frozen -- it's a strange thing to do to a Coin, but it's possible, and if you did it, you would "hide" it from the perspective of RPC, which we do not want to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case we should drop the partial index on owner_type = 1 then. The "correctness" is because of the partial index, so when querying for coins without using the same filtering condition in our query, we wouldn't end up using it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't quite understand this after reading the explanation. If there is a shared coin of some type, this filter would add owner_type = AddressOwner
to the query as well and the shared coin would not show up. Why is this right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would drop the partial index condition, and for queries, drop the filtering condition on owner_type as well
Description
coin.rs
needs to haveowner_type = 1
to use partial coin indexes.Add and modify coin indexes to support queries by coin and queries by coin and owner
Test plan
How did you test the new or updated feature?
Release notes
Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.
For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.