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

fix(hogql): Optimize querying for date frame in trends actors query #21060

Merged
merged 5 commits into from
Mar 21, 2024

Conversation

webjunkie
Copy link
Contributor

Problem

The query runner produces a query with e.g. toStartOfWeek(timestamp) = {our_time_frame} which has performance implications because seemingly CH must compute all timestamps and can only then match.

Changes

  • calculate the time range in Python

  • because for example

    toStartOfWeek(2024-03-21 12:01:10) = 2024-03-18   
    

    is the same as saying

    2024-03-21 12:01:10 >= 2024-03-18 00:00:00 and 2024-03-21 12:01:10 < 2024-03-25 00:00:00
    

Does this work well for both Cloud and self-hosted?

No impact

How did you test this code?

  • checked modals and tests

@webjunkie webjunkie requested a review from mariusandra March 21, 2024 08:58
Copy link
Contributor

github-actions bot commented Mar 21, 2024

Size Change: 0 B

Total Size: 824 kB

ℹ️ View Unchanged
Filename Size
frontend/dist/toolbar.js 824 kB

compressed-size-action

Copy link
Collaborator

@mariusandra mariusandra left a comment

Choose a reason for hiding this comment

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

👍

posthog/hogql_queries/utils/query_date_range.py Outdated Show resolved Hide resolved
@webjunkie webjunkie enabled auto-merge (squash) March 21, 2024 12:24
@webjunkie webjunkie merged commit c491bf2 into master Mar 21, 2024
126 of 127 checks passed
@webjunkie webjunkie deleted the fix/trends-actors-date-optimize branch March 21, 2024 12:44
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