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

Denormalize action_receipt_actions table in order to improve common queries performance #87

Closed
7 tasks done
frol opened this issue Apr 6, 2021 · 1 comment · Fixed by #99
Closed
7 tasks done
Labels
enhancement New feature or request

Comments

@frol
Copy link
Contributor

frol commented Apr 6, 2021

  • add columns to action_receipt_actions table and enable indices for them:

    • predecessor_account_id
    • receiver_account_id
    • included_in_block_timestamp

    The motivation is that JOINing with receipts table while doing filtering like receiver_account_id = ? AND action_kind = ? AND args = ? is slow. @vgrichina Could you provide a minimal useful query?

    Ideally, we want to have cross-table indices, but Postgres does not support that, though Postgres 12 and 13 claim to improve various aspects of index performance, so we may want to try to migrate our Postgres 11 database to Postgres 13 to see if that helps.

  • add index on args->>'method_name' for FUNCTION_CALL actions (conditional index in Postgres)

  • try to decode base64-encoded args->>args_base64 to JSON (replace the original base64 field with args->>args_json if parsing succeeds), so ultimately we will either have args_base64 (e.g. rainbow bridge uses borsh instead of JSON args) or args_json (commonly used by NEAR smart contracts)

    • consider adding indices to args->>'args_json'->>'receiver_id' and args->>'args_json'->>'amount' for FT and NFT
@frol frol added the enhancement New feature or request label Apr 6, 2021
@telezhnaya
Copy link
Contributor

It is also useful to have block_height near block_hash column in all places where applicable (we have block_hash almost everywhere).
It is easier to understand height (compare to timestamp which is unreadable).
I do not insist on it, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants