Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wlmyng
Copy link
Contributor

@wlmyng wlmyng commented May 16, 2024

Description

coin.rs needs to have owner_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.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • Indexer:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:

… and modify necessary coin indexes to support coin queries
Copy link

vercel bot commented May 16, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) May 16, 2024 5:43pm
sui-kiosk ⬜️ Ignored (Inspect) May 16, 2024 5:43pm
sui-typescript-docs ⬜️ Ignored (Inspect) May 16, 2024 5:43pm

Copy link
Contributor

@stefan-mysten stefan-mysten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +407 to +409
// 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))
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

@emmazzz emmazzz May 29, 2024

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?

Copy link
Contributor Author

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

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.

None yet

4 participants