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

Stop segment queries when not needed #5043

Merged
merged 1 commit into from
Feb 4, 2025

Conversation

apata
Copy link
Contributor

@apata apata commented Feb 3, 2025

Changes

When investigating some traces, we found that there's more database queries happening than needed. This removes one of them, which was running on all stats requests.

Tests

  • Existing controller tests should cover this

Changelog

  • This PR does not make a user-facing change

Documentation

  • This change does not need a documentation update

Dark mode

  • This PR does not change the UI

@apata apata force-pushed the stop-segment-queries-when-not-needed branch from d173dd9 to b76118e Compare February 3, 2025 16:15
@apata apata force-pushed the stop-segment-queries-when-not-needed branch from b76118e to bf8f589 Compare February 3, 2025 16:20
@@ -39,7 +39,13 @@ defmodule Plausible.Segments do

@spec get_many(Plausible.Site.t(), list(pos_integer()), Keyword.t()) ::
{:ok, [Segment.t()]}
def get_many(%Plausible.Site{} = site, segment_ids, opts) when is_list(segment_ids) do
def get_many(%Plausible.Site{} = _site, segment_ids, _opts)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think pattern matching directly instead of using when would work here (?)

def get_many(%Plausible.Site{} = _site, [], _opts) do

@apata apata added this pull request to the merge queue Feb 4, 2025
Merged via the queue into master with commit 15d78bd Feb 4, 2025
8 checks passed
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