Maintain all SQL statements in dedicated ORM package
Currently, we keep SQL statements for various queries and updates distributed across the Praefect codebase. In order to properly review and maintain these statements, we should keep them in a dedicated package where they can be benchmarked, abstracted, and reviewed in one place. This way, the complexity of higher level constructs, such as the datastore or node manager, won't complicate the understanding of the ORM abstractions during review. Details of proposal:
-
Move all SQL statements needed during Praefect runtime to a dedicated ORM package in internal/praefect/postgres/orm
. -
ORM should abstract away all details about SQL - besides constructor, interface should not leak SQL specific types
- interface should return Praefect domain types and parameters should be non empty-interface types
-
Devise test framework for loading Praefect production database dump and running various queries for benchmarking
Relates to #2944 (closed)
Edited by Paul Okstad (ex-GitLab)