Skip to content

Optimize app startup with Materialized View for trip statistics#45

Open
srepetsk wants to merge 2 commits into
developfrom
feature/improveStartupTime
Open

Optimize app startup with Materialized View for trip statistics#45
srepetsk wants to merge 2 commits into
developfrom
feature/improveStartupTime

Conversation

@srepetsk

Copy link
Copy Markdown
Owner
  • Implemented 'station_trip_stats_mv' PostgreSQL materialized view to pre-calculate station-to-station average and median trip durations.
  • Refactored 'TrainService' to query the materialized view at startup, eliminating the N+1 query bottleneck against the 12M+ row history table.
  • Added 'refreshTripStatsView' scheduled task to refresh the view nightly at 4 AM.
  • Added 'sql/create_station_trip_stats_mv.sql' migration script.
  • Updated README.md with instructions for initializing the materialized view in local and server environments.

- Implemented 'station_trip_stats_mv' PostgreSQL materialized view to pre-calculate station-to-station average and median trip durations.
- Refactored 'TrainService' to query the materialized view at startup, eliminating the N+1 query bottleneck against the 12M+ row history table.
- Added 'refreshTripStatsView' scheduled task to refresh the view nightly at 4 AM.
- Added 'sql/create_station_trip_stats_mv.sql' migration script.
- Updated README.md with instructions for initializing the materialized view in local and server environments.
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.

1 participant