bcgov / lcfs

An online application for fuel suppliers to manage their compliance obligations under the Low Carbon Fuels Act
Apache License 2.0
5 stars 3 forks source link

LCFS - Optimize SQLAlchemy Session Management for Enhanced Database Efficiency in FastAPI Integration #545

Open AlexZorkin opened 7 months ago

AlexZorkin commented 7 months ago

Describe the Task

Review and refactor the backend Python FastAPI integration with the PostgreSQL database focusing on the SQLAlchemy session management. The current implementation is leading to redundant database commits within a single request cycle, which unnecessarily increases the number of database calls. The aim is to streamline session management to ensure optimal performance and database interaction efficiency.

Purpose

The main goal of this task is to eliminate unnecessary database commits that occur multiple times within a single request cycle. By refining the session management strategy and adhering to a more efficient pattern, we aim to reduce the load on the database, enhance the application's performance, and ensure the scalability of our backend services. This task will contribute to improving the overall reliability and efficiency of our application.

Acceptance Criteria

Additional Context

AlexZorkin commented 6 months ago

This refactor has resulted in re-writing our service methods to allow for un-committed session objects. Estimate bumped from 3 to 5.