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

feat(postgres): complete implementation of driver and apply more tests #1785

Merged
merged 7 commits into from
Jun 9, 2023

Conversation

Ivansete-status
Copy link
Collaborator

@Ivansete-status Ivansete-status commented Jun 8, 2023

Summary

postgres_driver retention policy methods plus more tests

Changes

  • postgres_driver: Completing retention policy methods and corresponding unit tests.
  • Addition of 'test_driver_postgres_query.nim' which performs the same validation as in '*sqlite_query.nim' but for PostgreSQL.

Issue

#1604

@Ivansete-status Ivansete-status marked this pull request as ready for review June 8, 2023 10:08
@Ivansete-status Ivansete-status self-assigned this Jun 8, 2023
query: string,
args: seq[string] = newSeq[string](0)):
Future[Result[seq[Row], string]] {.async.} =
proc runQuery*(pool: PgAsyncPool,
Copy link
Member

Choose a reason for hiding this comment

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

why the rename?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick, but would also stick with query here. "Query" can be both a verb and noun, if it's about sticking to verb names for procs? :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

hehe, the reason was to avoid the next :)

let rowsRes = await s.connPool.query(query, args)
and instead have:
let rowsRes = await s.connPool.runQuery(query, args)

Copy link
Member

Choose a reason for hiding this comment

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

Hmm..no strong feelings TBH:)

But I am a sucker for consistency, so I checked the SQLite implementation: https://github.com/waku-org/nwaku/blob/master/waku/common/sqlite/database.nim#L223

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point! I'll rename it back to keep it consistent. With less priority though, I'll submit a separate PR to try to enhance that proc name.
Thanks!

Future[ArchiveDriverResult[void]] {.async.} =

let execRes = await s.connPool.exec(
"""DELETE FROM messages WHERE id NOT IN
Copy link
Member

Choose a reason for hiding this comment

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

Probably not a problem, but this could potentially result in large set of IN, not sure if there could be some performance penalty when a lot of messages (thousands?) would need to be deleted. On the other hand, my SQL-fu is weak, so not sure if there is another way:)

Copy link
Member

Choose a reason for hiding this comment

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

Ok, disregard, seems like this is actually the recommended way of doing it in postgres:)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the comment! We'll make performance tweaks in further phases.

Copy link
Contributor

@jm-clius jm-clius left a comment

Choose a reason for hiding this comment

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

Thanks!

@Ivansete-status Ivansete-status merged commit 5fc5770 into master Jun 9, 2023
@Ivansete-status Ivansete-status deleted the feat-1604-complete-waku-archive-postgres branch June 9, 2023 10:42
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.

3 participants