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

chore(postgres): Optimize the database. #1842

Closed
2 tasks done
Tracked by #1888
Ivansete-status opened this issue Jul 5, 2023 · 6 comments
Closed
2 tasks done
Tracked by #1888

chore(postgres): Optimize the database. #1842

Ivansete-status opened this issue Jul 5, 2023 · 6 comments
Assignees
Labels
E:PostgreSQL See https://github.com/waku-org/pm/issues/84 for details

Comments

@Ivansete-status
Copy link
Collaborator

Ivansete-status commented Jul 5, 2023

Background

When nwaku has the "store/archive" protocol mounted it can store and retrieve historical messages. All this information is kept in a single table, messages. We need to optimize this.

Details

We need to get the maximum performance possible with regard to insert/select operations.
We need a rapid response when duplicate msgs happens. For that, we may need to adapt how the message id is generated so that we achieve high selectivity.

Tasks

  • [ ] Rename the messages table to MESSAGE. (that renaming caused issues in the current existing shards.test fleet.
    - [ ] Apply @Menduist 's enhancement suggestions for a more appropriate asynchronous handling: feat(common): added postgress async pool wrapper #1631 (comment)
  • Perform tests in a standalone database. This is a DB analyst task where operations are checked in a table with hundreds of millions of rows.
  • Apply "integration" performance tests.
    ℹ️ We understand that a query performance is acceptable in Grafana by checking that "Waku Archive Query Duration" is <50ms.
    ℹ️ For that, we will use the next repo: https://github.com/waku-org/test-waku-query (cc - @richard-ramos )

Related issue

#1604

@jm-clius
Copy link
Contributor

jm-clius commented Jul 15, 2023

  • add an index column with the consistent, deterministic message hash as message ID.

edited: being considered in #2112

@Ivansete-status
Copy link
Collaborator Author

<<Apply "integration" performance tests.>> This is done in the https://github.com/waku-org/test-waku-query repo

@Ivansete-status
Copy link
Collaborator Author

I'm reluctant to perform the @Menduist enhancement. We might still have a bottleneck in while pqIsBusy(db) == 1: for concurrent Store queries (see TODO comment in

while db.pqisBusy() == 1:
)

@Ivansete-status
Copy link
Collaborator Author

Ivansete-status commented Nov 7, 2023

Tests had been performed in the database itself with ~12 million rows. On the other hand, the bottleneck is within the db.pqisBusy() as mentioned above. See also https://www.notion.so/Postgres-e33d8e64fa204c4b9dcb1514baf9c582

@Ivansete-status
Copy link
Collaborator Author

  • add an index column with the consistent, deterministic message hash as message ID.

Thanks for adding this point @jm-clius!
I'll check it in this issue because it is properly being tackled in #2112 by @ABresting
Cheers

@Ivansete-status
Copy link
Collaborator Author

We conclude the Postgres optimization for now.
Find more details in https://github.com/waku-org/nwaku/wiki/Adoption-of-Postgres-as-an-archive-system

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E:PostgreSQL See https://github.com/waku-org/pm/issues/84 for details
Projects
Archived in project
Development

No branches or pull requests

5 participants