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

GetMessagesByAddress optimisation #306

Closed
ryuash opened this issue Jan 12, 2022 · 6 comments · Fixed by #356
Closed

GetMessagesByAddress optimisation #306

ryuash opened this issue Jan 12, 2022 · 6 comments · Fixed by #356
Assignees

Comments

@ryuash
Copy link

ryuash commented Jan 12, 2022

Currently when the Tx table gets too big GetMessagesByAddress will stop working correctly. This might be an issue with missing indexes.

Below is the query i'm currently using:

query GetMessagesByAddress($address: _text, $limit: bigint = 50, $offset: bigint = 0 $types: _text = "{}") {
  messagesByAddress: messages_by_address(args: {addresses: $address, types: $types, limit: $limit, offset: $offset}) {
    transaction {
      height
      hash
      success
      messages
      logs
      block {
        height
        timestamp
      }
    }
  }
}

Even if the limit is set to 10 the data will not return.
This is currently happening on Band and Sifchain

@RiccardoM
Copy link
Contributor

I think this is due to the fact that the message table which this query is relying on did not have the following indexes:

CREATE INDEX message_type_index ON message (type);
CREATE INDEX message_involved_accounts_addresses ON message (involved_accounts_addresses);

I have now tried creating them on the PostgreSQL database for Desmos in both the testnet and the mainnet and I've pushed them here as well with 9db8eb1. @MonikaCat can you see if you can add them to the Band and SifChain databases to see whether they improve the mentioned query performance please?

@MonikaCat
Copy link
Contributor

@RiccardoM I have updated band and sifchain database with the above indexes. @ryuash Can you confirm if you can see improvement in the query performance?

@ryuash
Copy link
Author

ryuash commented Jan 14, 2022

@tgntr
Copy link

tgntr commented Feb 7, 2022

FYI we are having the same issue. I noticed that our instance CPU was overloading and we just tried adding an extra cpu core. So far it seems to do the job! Not sure if that's considered a workaround or if actually postgres really needs some processing power.

https://explorer-v2.cudos.org/

@tgntr
Copy link

tgntr commented Feb 7, 2022

By the way, have you considered trying postgres partitioning feature? Do you think it's worth checking out for our case?

@huichiaotsou
Copy link
Contributor

we applied partitioning in staging environment and it looks promising :D
we will update soon

@mergify mergify bot closed this as completed in #356 Apr 1, 2022
mergify bot pushed a commit that referenced this issue Apr 1, 2022
## Description
This PR updated Juno to `v3.0.0`. 

Closes: #282
Closes: #346
Closes: #306



---

### Author Checklist

*All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.*

I have...

- [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [x] targeted the correct branch
- [x] provided a link to the relevant issue or specification
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [x] reviewed "Files changed" and left comments if necessary
- [x] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.*

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants