Skip to content

Config option to use materialized views for active entities#518

Merged
irees merged 3 commits intomainfrom
use-materialized
Oct 21, 2025
Merged

Config option to use materialized views for active entities#518
irees merged 3 commits intomainfrom
use-materialized

Conversation

@irees
Copy link
Copy Markdown
Contributor

@irees irees commented Oct 21, 2025

No description provided.

@irees irees marked this pull request as ready for review October 21, 2025 22:25
@irees irees requested a review from Copilot October 21, 2025 22:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a configuration option to use materialized views for querying active GTFS entities (agencies, routes, and stops), which can improve query performance by pre-computing the active entity set.

  • Adds UseMaterialized boolean flag to the Config struct
  • Updates entity finder methods to conditionally use materialized view tables when both active filtering and the new flag are enabled
  • Introduces UseActive struct to pass both the active state and materialized view preference through the query builders

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
server/model/config.go Adds UseMaterialized configuration field
cmds/server_cmd.go Adds command-line flag and wires it to the Config
server/finders/dbfinder/finder.go Defines UseActive struct to encapsulate active state and materialized view usage
server/finders/dbfinder/stop.go Updates stop queries to use materialized views when configured
server/finders/dbfinder/route.go Updates route queries to use materialized views when configured
server/finders/dbfinder/agency.go Updates agency queries to use materialized views when configured

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

func routeSelect(limit *int, after *model.Cursor, ids []int, useActive *UseActive, permFilter *model.PermFilter, where *model.RouteFilter) sq.SelectBuilder {
routeTable := "gtfs_routes"
active := useActive != nil && useActive.Active
if active && useActive != nil && useActive.UseMaterialized {
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

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

The condition useActive != nil is redundant in line 188 since it's already checked in line 187 where active is set. Line 188 can be simplified to if active && useActive.UseMaterialized {.

Suggested change
if active && useActive != nil && useActive.UseMaterialized {
if active && useActive.UseMaterialized {

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Oct 21, 2025

Generated Code Check ✅

All generated code is up to date.

@irees irees merged commit 3a78be4 into main Oct 21, 2025
6 checks passed
@irees irees deleted the use-materialized branch October 21, 2025 22:41
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.

2 participants