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

[RFC] [indexer-alt] Add object filter queries #20847

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lxfind
Copy link
Contributor

@lxfind lxfind commented Jan 10, 2025

Description

This PR is to add queries that reads from the obj_info table. Still WIP, but sending out early.

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):
  • gRPC:
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:

Copy link

vercel bot commented Jan 10, 2025

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

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 10, 2025 5:39am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Jan 10, 2025 5:39am
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Jan 10, 2025 5:39am

Comment on lines +189 to +197
"(object_id = '\\x{}'::bytea AND cp_sequence_number <= {})",
hex::encode(&o.object_id),
o.cp_sequence_number
)
})
.collect::<Vec<_>>()
.join(" OR ");
let query = format!(
"
SELECT obj_versions.*
Copy link
Contributor

Choose a reason for hiding this comment

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

or filtering with postgres always makes me cry, it makes the query planner do inefficient stuff, usually. on graphql, what we've ended up doing is just to fetch the latest objects, and then filter in the application

Comment on lines 145 to 150
max_cp_per_object AS (
SELECT
object_id,
MAX(cp_sequence_number) AS max_cp_sequence_number
FROM
obj_info
WHERE
cp_sequence_number <= {view_checkpoint_number}
GROUP BY
object_id
)
Copy link
Contributor

Choose a reason for hiding this comment

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

This would scan the entire table right? I see that it's needed to filter out older object entries that might match the filtering conditions ... can't think of a neat way around this though. We could use a window function to find the latest version in a single pass?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry this query is out-of-dated! I forgot to update it to use LEFT JOIN

@lxfind lxfind force-pushed the xun/indexer-alt-obj-info-queries branch from 2453720 to a5bc652 Compare January 10, 2025 05:37
@lxfind lxfind deployed to sui-typescript-aws-kms-test-env January 10, 2025 05:38 — with GitHub Actions Active
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.

2 participants